Support appGuid or appId as Bluemix application GUID
diff --git a/packages/actions/sendMessage.js b/packages/actions/sendMessage.js
index af3bc1c..7d0d45f 100644
--- a/packages/actions/sendMessage.js
+++ b/packages/actions/sendMessage.js
@@ -1,5 +1,5 @@
/*
-* Copyright 2016-2017 IBM Corporation
+* Copyright 2016 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
* Action to Send Push Notification using IBM Push Notifications service
*
-* @param {string} appId - appId to create webhook
+* @param {string} appGuid - appGuid to create webhook
* @param {string} appSecret - appSecret of the application
* @param {string} url - An optional URL that can be sent along with the alert. Eg : -p url "https:\\www.w3.ibm.com".
* @param {object} text - The notification message to be shown to the user. Eg: -p text "Hi ,OpenWhisk send a notification"
@@ -66,7 +66,7 @@
function main(params) {
if (validateParams(params)) {
- var appId = params.appId;
+ var appId = params.appGuid || params.appId;
var appSecret = params.appSecret;
// message section settings
@@ -347,7 +347,7 @@
}
function validateParams(params) {
- if (!params.appId) {
+ if (!params.appId && !params.appGuid) {
whisk.error('appId / appGUID of the application is required.');
return false;
}
diff --git a/packages/feeds/webhook.js b/packages/feeds/webhook.js
index e066f04..1a6edda 100644
--- a/packages/feeds/webhook.js
+++ b/packages/feeds/webhook.js
@@ -16,7 +16,7 @@
/**
* Feed to create a webhook for IBM Push Notifications service
*
- * @param {string} appId - appId to create webhook
+ * @param {string} appGuid - appGuid to create webhook
* @param {string} appSecret - appSecret of the application
* @param {string} events - list of the events the webhook should fire on
* @return {object} whisk async
@@ -32,7 +32,7 @@
var endpoint = 'openwhisk.ng.bluemix.net';
// URL of the whisk system. The calls of push service will go here.
var whiskCallbackUrl = 'https://' + whisk.getAuthKey() + "@" + endpoint + '/api/v1/namespaces/' + namespace + '/triggers/' + trigger;
- var appId = params.appId;
+ var appId = params.appGuid || params.appId;
var appSecret = params.appSecret;
// The URL to create the webhook on push service
var registrationEndpoint = 'https://mobile.ng.bluemix.net/imfpush/v1/apps/' + appId + '/webhooks';
diff --git a/packages/installCatalog.sh b/packages/installCatalog.sh
index df9e248..798c92a 100755
--- a/packages/installCatalog.sh
+++ b/packages/installCatalog.sh
@@ -37,20 +37,20 @@
$WSK_CLI -i --apihost "$APIHOST" package update --auth "$AUTH" --shared yes "$NAMESPACE/pushnotifications" \
-a description "This package supports sending push notifications to your mobile device, using the IBM Bluemix Push Notifications service." \
--a parameters '[ {"name":"appId", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"}]' \
+-a parameters '[ {"name":"appGuid", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"}]' \
-a prettyName "Push Notifications" \
-p bluemixServiceName 'imfpush'
$WSK_CLI -i --apihost "$APIHOST" action update --auth "$AUTH" "$NAMESPACE/pushnotifications/webhook" "$PACKAGE_HOME/feeds/webhook.js" \
-a feed true \
-a description 'pushnotifications feed' \
--a parameters '[ {"name":"appId", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"},{"name":"events", "required":true, "description":"Name of the event user want to subscribe"} ]' \
--a sampleInput '{"appId":"xxx-xxx-xx", "appSecret":"yyy-yyy-yyy", "events":"onDeviceRegister"}' \
+-a parameters '[ {"name":"appGuid", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"},{"name":"events", "required":true, "description":"Name of the event user want to subscribe"} ]' \
+-a sampleInput '{"appGuid":"xxx-xxx-xx", "appSecret":"yyy-yyy-yyy", "events":"onDeviceRegister"}' \
-a sampleOutput '{"tagName": "tagName","eventType": "onDeviceRegister","applicationId": "xxx-xxx-xx"}'
$WSK_CLI -i --apihost "$APIHOST" action update --auth "$AUTH" "$NAMESPACE/pushnotifications/sendMessage" "$PACKAGE_HOME/actions/sendMessage.js" \
-a description 'Send push notification to all application users or to a specific set of devices' \
--a parameters '[ {"name":"appId", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"}, {"name":"text", "required":true, "description":"The notification message to be shown to the user"}, {"name":"url", "required":false, "description":"An optional URL that can be sent along with the alert"}, {"name":"deviceIds", "required":false, "description":"Array of device IDs"}, {"name":"platforms", "required":false, "description":"Array of device platform"},{"name":"tagNames", "required":false, "description":"Array of tag names"},{"name":"gcmPayload", "required":false, "description":"Additional payload"},{"name":"gcmSound", "required":false, "description":"Sound file name"},{"name":"gcmCollapseKey", "required":false, "description":"This parameter identifies a group of messages"},{"name":"gcmDelayWhileIdle", "required":false, "description":"Send message when device is active"}, {"name":"gcmPriority", "required":false, "description":"Sets the priority of the message"}, {"name":"gcmTimeToLive", "required":false, "description":"Time limit for message to be delievered"}, {"name":"gcmSync", "required":false, "description":"Device group messaging"}, {"name":"gcmVisibility", "required":false, "description":"private/public - Visibility of notification"}, {"name":"gcmStyleType", "required":false, "description":"Specifies the type of expandable notifications"}, {"name":"gcmStyleTitle", "required":false, "description":"Specifies the title of the notification"}, {"name":"gcmStyleUrl", "required":false, "description":"An URL from which the picture has to be obtained for the notification"}, {"name":"gcmStyleText", "required":false, "description":"The big text in bigtext_notification"}, {"name":"gcmStyleLines", "required":false, "description":"An array of strings for inbox_notification"}, {"name":"apnsBadge", "required":false, "description":"Value for Badge"}, {"name":"apnsCategory", "required":false, "description":"The category name"}, {"name":"apnsIosActionKey", "required":false, "description":"Title for the push notification action Key"},{"name":"apnsPayload", "required":false, "description":"Additional payload"},{"name":"apnsType", "required":false, "description":"Push notification type name"},{"name":"apnsSound", "required":false, "description":"APNS sound name"}, {"name":"fireFoxTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"fireFoxIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification."}, {"name":"fireFoxTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline."}, {"name":"fireFoxPayload", "required":false, "description":"Custom JSON payload"}, {"name":"chromeTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"chromeIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification"}, {"name":"chromeTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline."}, {"name":"chromePayload", "required":false, "description":"Custom JSON payload"}, {"name":"chromeAppExtTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"chromeAppExtCollapseKey", "required":false, "description":"This parameter identifies a group of messages"}, {"name":"chromeAppExtDelayWhileIdle", "required":false, "description":"When this parameter is set to true, it indicates that the message should not be sent until the device becomes active"}, {"name":"chromeAppExtIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification"}, {"name":"chromeAppExtTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline"}, {"name":"chromeAppExtPayload", "required":false, "description":"Custom JSON payload"}]' \
--a sampleInput '{"appId":"xxx-xxx-xx", "appSecret":"yyy-yyy-yyy", "text":"hi there"}' \
+-a parameters '[ {"name":"appGuid", "required":true, "bindTime":true, "description":"Bluemix application GUID"}, {"name":"appSecret", "required":true, "bindTime":true, "type":"password", "description":"Bluemix Push Service Secret"}, {"name":"text", "required":true, "description":"The notification message to be shown to the user"}, {"name":"url", "required":false, "description":"An optional URL that can be sent along with the alert"}, {"name":"deviceIds", "required":false, "description":"Array of device IDs"}, {"name":"platforms", "required":false, "description":"Array of device platform"},{"name":"tagNames", "required":false, "description":"Array of tag names"},{"name":"gcmPayload", "required":false, "description":"Additional payload"},{"name":"gcmSound", "required":false, "description":"Sound file name"},{"name":"gcmCollapseKey", "required":false, "description":"This parameter identifies a group of messages"},{"name":"gcmDelayWhileIdle", "required":false, "description":"Send message when device is active"}, {"name":"gcmPriority", "required":false, "description":"Sets the priority of the message"}, {"name":"gcmTimeToLive", "required":false, "description":"Time limit for message to be delievered"}, {"name":"gcmSync", "required":false, "description":"Device group messaging"}, {"name":"gcmVisibility", "required":false, "description":"private/public - Visibility of notification"}, {"name":"gcmStyleType", "required":false, "description":"Specifies the type of expandable notifications"}, {"name":"gcmStyleTitle", "required":false, "description":"Specifies the title of the notification"}, {"name":"gcmStyleUrl", "required":false, "description":"An URL from which the picture has to be obtained for the notification"}, {"name":"gcmStyleText", "required":false, "description":"The big text in bigtext_notification"}, {"name":"gcmStyleLines", "required":false, "description":"An array of strings for inbox_notification"}, {"name":"apnsBadge", "required":false, "description":"Value for Badge"}, {"name":"apnsCategory", "required":false, "description":"The category name"}, {"name":"apnsIosActionKey", "required":false, "description":"Title for the push notification action Key"},{"name":"apnsPayload", "required":false, "description":"Additional payload"},{"name":"apnsType", "required":false, "description":"Push notification type name"},{"name":"apnsSound", "required":false, "description":"APNS sound name"}, {"name":"fireFoxTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"fireFoxIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification."}, {"name":"fireFoxTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline."}, {"name":"fireFoxPayload", "required":false, "description":"Custom JSON payload"}, {"name":"chromeTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"chromeIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification"}, {"name":"chromeTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline."}, {"name":"chromePayload", "required":false, "description":"Custom JSON payload"}, {"name":"chromeAppExtTitle", "required":false, "description":"Specifies the title to be set for the WebPush Notification"}, {"name":"chromeAppExtCollapseKey", "required":false, "description":"This parameter identifies a group of messages"}, {"name":"chromeAppExtDelayWhileIdle", "required":false, "description":"When this parameter is set to true, it indicates that the message should not be sent until the device becomes active"}, {"name":"chromeAppExtIconUrl", "required":false, "description":"The URL of the icon to be set for the WebPush Notification"}, {"name":"chromeAppExtTimeToLive", "required":false, "description":"This parameter specifies how long (in seconds) the message should be kept in GCM storage if the device is offline"}, {"name":"chromeAppExtPayload", "required":false, "description":"Custom JSON payload"}]' \
+-a sampleInput '{"appGuid":"xxx-xxx-xx", "appSecret":"yyy-yyy-yyy", "text":"hi there"}' \
-a sampleOutput '{"pushResponse": {"messageId":"11111s","message":{"message":{"alert":"register for tag"}}}}'
diff --git a/tests/src/packages/PushNotificationsTests.scala b/tests/src/packages/PushNotificationsTests.scala
index cb11d53..55d4a07 100644
--- a/tests/src/packages/PushNotificationsTests.scala
+++ b/tests/src/packages/PushNotificationsTests.scala
@@ -30,7 +30,7 @@
val credentials = TestUtils.getVCAPcredentials("imfpush")
val appSecret = credentials.get("appSecret").toJson;
val credentialsUrl = credentials.get("url");
- val appId = credentialsUrl.split("/").last.toJson;
+ val appGuid = credentialsUrl.split("/").last.toJson;
val url = "www.google.com".toJson;
val messageText = "This is pushnotifications Testing".toJson;
@@ -39,14 +39,14 @@
it should "Send Notification action" in {
val name = "/whisk.system/pushnotifications/sendMessage"
- withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appId" -> appId, "text" -> messageText))){
+ withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> messageText))){
_.response.result.get.toString should include ("message")
}
}
it should "Send Notification action with url" in {
val name = "/whisk.system/pushnotifications/sendMessage"
- withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appId" -> appId, "text" -> messageText, "url"-> url))){
+ withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appGuid" -> appGuid, "text" -> messageText, "url"-> url))){
_.response.result.get.toString should include ("message")
}
}