commit | a771901de4dfbb500f782e607bedce2b5c6bc5ab | [log] [tgz] |
---|---|---|
author | Ananth <agirijak@in.ibm.com> | Mon May 23 17:11:40 2016 +0530 |
committer | Ananth <agirijak@in.ibm.com> | Mon May 23 17:11:40 2016 +0530 |
tree | f37940c4c303bc5a08ae6f4d2997b27e3ee36634 | |
parent | 4939257df936c84058788da0a2befad1e74380ae [diff] |
Modified action and webhook
The /whisk.system/pushnotifications
package enables you to work with a push service. It includes the following action and feed.
Entity | Type | Parameters | Description |
---|---|---|---|
/whisk.system/pushnotifications | package | appId, appSecret | Work with the Push Service |
/whisk.system/pushnotifications/sendMessage | action | text, url, deviceIds, platforms, tagNames, apnsBadge, apnsCategory, apnsActionKeyTitle, apnsSound, apnsPayload, apnsType, gcmCollapseKey, gcmDelayWhileIdle, gcmPayload, gcmPriority, gcmSound, gcmTimeToLive | Send push notification to the specified device(s) |
/whisk.system/pushnotifications/webhook | feed | events | Fire trigger events on device activities (device (un)registration / (un)subscription) on the Push Service |
Even though its not mandatory , it‘s suggested that you create a package binding with the appId and appSecret values. This way you don’t need to specify these credentials every time you invoke the actions in the package. |
While creating a IBM Push Notifications package you have to give the following parameters,
appId
: The Bluemix app GUID.appSecret
: The Bluemix push notification service appSecret.The following is an example of creating a package binding.
Create a Bluemix application in Bluemix Dashboard.
Initialize the Push Notification Service and bind the service to the Bluemix application
Configure the IBM Push Notification application.
Be sure to remember the App GUID
and the App Secret
of the Bluemix app you created.
Make sure your OpenWhisk CLI is in the namespace corresponding to the Bluemix organization and space that you used in the previous step.
$ wsk property set --namespace myBluemixOrg_myBluemixSpace
Alternatively, you can use
wsk property set --namespace
to set a namespace from a list of those accessible to you.
/whisk.system/pushnotifications
.wsk package bind /whisk.system/pushnotifications myPush -p appId "myAppID" -p appSecret "myAppSecret"
wsk package list
packages /myNamespace/myPush private binding
The /whisk.system/pushnotifications/sendMessage
action sends push notifications to registered devices. The parameters are as follows:
text
- The notification message to be shown to the user. Eg: -p text “Hi ,OpenWhisk send a notification”.url
: An optional URL that can be sent along with the alert. Eg : -p url “https:\www.w3.ibm.com”.gcmPayload
- Custom JSON payload that will be sent as part of the notification message. Eg: -p gcmPayload “{“hi”:“hello”}”gcmSound
- The sound file (on device) that will be attempted to play when the notification arrives on the device .gcmCollapseKey
- This parameter identifies a group of messagesgcmDelayWhileIdle
- When this parameter is set to true, it indicates that the message should not be sent until the device becomes active.gcmPriority
- Sets the priority of the message.gcmTimeToLive
- This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline.apnsBadge
- The number to display as the badge of the application icon.apnsCategory
- The category identifier to be used for the interactive push notifications .apnsIosActionKey
- The title for the Action key .apnsPayload
- Custom JSON payload that will be sent as part of the notification message.apnsType
- [‘DEFAULT’, ‘MIXED’, ‘SILENT’].apnsSound
- The name of the sound file in the application bundle. The sound of this file is played as an alert.Here is an example of sending push notification from the pushnotification package.
sendMessage
action in the package binding that you created previously. Be sure to replace /myNamespace/myPush
with your package name.wsk action invoke /myNamespace/myPush/sendMessage --blocking --result -p url https://example.com -p text "this is my message3" -p sound soundFileName -p deviceIds '["T1","T2"]'
{ "result": { "pushResponse": "{"messageId":"11111H","message":{"message":{"alert":"this is my message3","url":"http.google.com"},"settings":{"apns":{"sound":"default"},"gcm":{"sound":"default"},"target":{"deviceIds":["T1","T2"]}}}" }, "status": "success", "success": true }
The /whisk.system/pushnotifications/webhook
configures the IBM Push Notifications service to fire a trigger when there is a device activity such as device registration / unregistration or subscription / unsubscription in a specified application
The parameters are as follows:
appId:
The Bluemix push notification service appSecret.appSecret:
The Bluemix app GUID.events:
Supported events are onDeviceRegister
, onDeviceUnregister
, onSubscribe
, onUnsubscribe
.To get notified for all events use the wildcard character *
.The following is an example of creating a trigger that will be fired each time there is a new device registered with the IBM Push Notifications Service application.
$ wsk package bind /whisk.system/pushnotifications myNewDeviceFeed --param appID myapp --param appSecret myAppSecret --param events onDeviceRegister
onDeviceRegister
event type using your myPush/webhook
feed.$ wsk trigger create myPushTrigger --feed myPush/webhook --param events onDeviceRegister