The com.innovaphone.launcher api enables apps to communicate with the launcher itself, e.g. to send notifications etc.
The client consumeApi function is used to access the Api:
var dis = start.consumeApi("com.innovaphone.launcher")
Adds a notification, which will be opened by the corresponding launcher. You can receive user actions on this notification!
var title = "Call by " + (call.getDN() || call.getURI() || call.getE164() || str.anonymous);
var largeIcon = call.getURI() ? self.avatarApi.url(call.getURI(), "240", call.getDN()) : null;
launcherApi.send({ mt: "AddLocalNotification", title: title, text: null, acceptTitle: str.connect, rejectTitle: str.reject, largeIcon: largeIcon }, "*", call.id().toString());
string src | A unique src for this notification. This src is also used to remove the notification later. |
string type | The type of the notification ("Default", "PhoneCall" or "ChatMessage"). |
string title | The title of the notification. |
string text | The text of the notification (e.g. chat message). |
string smallIcon | A smallIcon of the notification. |
string largeIcon | A largeIcon of the notification (e.g. a URL to a profile picture). |
string soundUrl | A URL with a sound file to play. It can be set to "*" to play a default sound. |
string buttonTitle | The button title for a one button notification or a third "view" button in a call notification. |
string acceptTitle | The accept button title for a call notification. |
string rejectTitle | The reject button title for a call notification. |
string replyTitle | The reply button title for a chat notification. |
chat notification | type:"ChatMessage", set replyTitle |
call notification | type:"PhoneCall", set rejectTitle and acceptTitle (buttonTitle optional) |
one button notification | type:"Default", set buttonTitle |
two button notification | type:"Default", set rejectTitle and acceptTitle |
no button notification | type:"Default", do not set any *Title |
This callback is triggered through the api on user interaction with the notification.
launcherApi.onmessage.attach(function (consumer, obj) {
if (obj.msg.mt == "LocalNotificationClicked") {
if (obj.msg.action == "accept") { // accepted
}
else if (obj.msg.action == "reject") { // rejected
}
else if (obj.msg.action == "reply") { // reply with input
// obj.msg.replyText contains the text
}
else { // default action, e.g. open the current chat/call/etc.
}
self.BringToFront();
}
});
string src | The src for this notification. |
string action | Can be empty or accept|reject|reply. |
string replyText | The reply text. |
Removes an existing notification.
launcherApi.send({ mt: "RemoveLocalNotification" }, "*", call.id().toString());
string src | The original src of the notification. |