-
Notifications
You must be signed in to change notification settings - Fork 6
Notify
Allows subscription and unsubscription from System Event Notifications and Local Notifications. (Local Notifications are not supported for Electron.)
URL: http://pmapi/notify/events/{notificationName}
Input: JSON Dictionary containing key "script", whose value is a JavaScript function to call when the notification of notificationName occurs.
If the notificationName notification has associated data object that is serializable into JSON, the object will be passed to the script function by default as the first parameter.
The script parameter can contain simply a method name, without trailing parentheses (e.g. "methodName", instead of "methodName()"). When this is the case, the string "({});", is appended to the method name. (e.g. for the script "methodName", the final script becomes "methodName({});")
Tokens {}
and {notificationName}
can be used to control the script parameters.
-
{}
is substituted for the notification object -
{notificationName}
is substituted for the name of the notification
Output: Standard HTTP status codes.
POST Examples:
Assume a notification exists called "SomeNotification" this notification includes a data of an array with values "foo" and "bar"
Example Case 1:
Request-> http://pmapi/notify/events/SomeNotification
POST data: { "script" : "myFunction" }
Result call -> myFunction(["foo", "bar"]);
- Example Case 2:
Request-> http://pmapi/notify/events/SomeNotification POST data: { "script" : "myFunction({}, "static_parameter");" } Result call -> myFunction(["foo", "bar"], "static_parameter"); - Example Case 3:
Request-> http://pmapi/notify/events/SomeNotification POST data: { "script" : "myFunction({}, {notificationName});" } Result call -> myFunction(["foo", "bar"], "SomeNotification"); - Example Case 4:
Request-> http://pmapi/notify/events/SomeNotification POST data: { "script" : "myFunction({notificationName});" } Result call -> myFunction("SomeNotification"); Note in the above case, parameters were supplied, but not the {} token, so the notification object is not returned
Example Case 5: Subscribing to notifications of Document changes
Use this api request to subscribe to call a javascript function whenever a document specified by docid is changed.
Request-> http://pmapi/notify/events/DocumentChangedNotification/myDocId
POST data: { "script" : "myFunction({}, {notificationName});" }
Result call -> myFunction({“documentID”:”myDocId”, “fromReplication”:false, “revisionID”:”2-398df29a31473c”, “isCurrentRevision”:true, ”inConflict”:false, “value”:”bar”}, “DocumentChangedNotification/myDocId")
URL: http://pmapi/notify/events
Output: Standard HTTP status codes.
Unsubscribes from all currently subscribed notifications.
Method: DELETE
URL: http://pmapi/notify/events/{notificationName}
Output: Standard HTTP status codes.
Unsubscribes from notificationName notification.
URL: http://pmapi/notify/events
Output: Standard HTTP status codes, and response data JSON dictionary all currently subscribed notifications. The key of the dictionary will be the notification names, the values will be the javascript function called.
Method: GET
URL: http://pmapi/notify/events/{notificationName}
Output: HTTP status code 200 if the notificationName notification is subscribed, otherwise status code 404. Returns no data.
URL: http://pmapi/notify/attime
Input: JSON Dictionary containing elements:
-
date: Date is expected to be ISO 8601 format matching: "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
example: "2015-10-18T11:00:00-07:00" is October 18th, 2015 at 11am PDT
Alternative ISO 8601 format "yyyy-MM-dd'T'HH:mm:ss.SSSXX" is also supported. This is the format used by most browsers when calling 'date.toISOString()' - prompt: Notification text to display when application is backgrounded
- title: optional Notification title to display (iOS 8.2 and above)
- script: optional Javascript method to call when notification fires
All other elements are kept and passed to script when called.
In the script element the token {}
can be used to control where the parameter dictionary is passed to the script.
An additional element notificationId will be added to the payload dictionary. This is a unique identifier for this notification.
Output: Standard HTTP status codes.
Examples:
Request-> http://pmapi/notify/attime
POST data: { "script" : "myFunction", "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Time is up", "additional" : "value"}
Result call -> myFunction({ "script" : "myFunction", "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Time is up", "additional" : "value", "notificationId" : "abc123"});
-
Request-> http://pmapi/notify/attime POST data: { "script" : "myFunction('another_parameter', {})", "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Time is up", "additional" : "value"} Result call -> myFunction('another_parameter', { "script" : "myFunction", "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Time is up", "additional" : "value", "notificationId" : "abc123"});
-
Request-> http://pmapi/notify/attime POST data: { "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Reminder!"} No result call will be made, but if the application is backgrounded the notification "Reminder!" will appear.
URL: http://pmapi/notify/attime
Output: Array of dictionaries containing for all registered notifications for the app.
Examples:
Request-> http://pmapi/notify/attime
Response: [{"script" : "myFunction", "date" : "2015-10-18T11:00:00-07:00", "prompt" : "Time is up", "additional" : "value", "notificationId" : "abc123"}, {"script" : "myFunction", "date" : "2015-10-18T11:30:00-07:00", "prompt" : "Another reminder", "notificationId" : "def456"}]
URL: http://pmapi/notify/attime
Output: Standard HTTP status codes.
Deletes all local notifications for this app
Method: DELETE
URL: http://pmapi/notify/attime/{notificationId}
Output: Standard HTTP status codes.
Deletes the specified notificationId local notification
Intro *Home
Services
- Authentication
- Boot
- Command
- Connectivity
- Data Access High-level
- Data Access Low-level
- Logging
- Notify
- OpenURL
- Secure Storage
- TouchId
- User Information
- User Settings
- Version
- Window
iOS SDK
- General
- Posted Notifications
- Remote Notifications
- Classes
- PredixMobilityConfiguration
- PredixMobilityManager
- Protocols
- PredixAppWindowProtocol
iOS Examples
Java Examples
General
[//]: (Enabling Sync Logging)