From ece4b5d5a7d805c0ddf3096032c13220a0ff1074 Mon Sep 17 00:00:00 2001 From: anudas2345 <37937506+anudas2345@users.noreply.github.com> Date: Sun, 15 Apr 2018 06:08:04 +0530 Subject: [PATCH] Update README.md --- README.md | 164 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 85 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 5027c7b..7dfaeca 100755 --- a/README.md +++ b/README.md @@ -2,104 +2,110 @@ A node module to help you send downstream message to a client. -Installation +## Installation npm install @star8/firebase-message-node --save -Sample usage +## Sample usage To send message synchronously -1. send notification - -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, - -notification: { - title: "Dummy Title", - icon: "test icon ", - body: "This is a notification that will be displayed if your app is in the background." -}, -registrationIDs:[ user_registration_token'] -} -) - -firebaseMsg.send(); - - -2. Send message - - - - -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, -data{ -"KEY1": "VALUE1", -"KEY2": "VALUE2" -}, -registrationIDs:[ user_registration_token'] -} -) -firebaseMsg.send(); - -3.Send message & notification - -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, -notification: { - title: "Dummy Title", - icon: "test icon ", - body: "This is a notification that will be displayed if your app is in the background." -}, -data{ -"KEY1": "VALUE1", -"KEY2": "VALUE2" -}, -registrationIDs:[ user_registration_token'] -} -) -firebaseMsg.send(); + + 1.send notification + + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + + notification: { + title: "Dummy Title", + icon: "test icon ", + body: "This is a notification that will be displayed if your app is in the background." + }, + registrationIDs:[ user_registration_token'] + } + ) + + firebaseMsg.send(); + + 2.Send message + + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + data{ + "KEY1": "VALUE1", + "KEY2": "VALUE2" + }, + registrationIDs:[ user_registration_token'] + } + ) + + firebaseMsg.send(); + + 3.Send message & notification + + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + notification: { + title: "Dummy Title", + icon: "test icon ", + body: "This is a notification that will be displayed if your app is in the background." + }, + data{ + "KEY1": "VALUE1", + "KEY2": "VALUE2" + }, + registrationIDs:[ user_registration_token'] + } + ) + + firebaseMsg.send(); + + To create Group of devices for single user having multiple devices -1.Create Group of Devices + 1.Create Group of Devices + + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + registrationIDs:[ user_registration_token'], + notification_key_name:"1234_3" + } + ) + var notification_key = firebaseMsg.createDeviceGroup(); -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, -registrationIDs:[ user_registration_token'], -notification_key_name:"1234_3" -} -) -var notification_key = firebaseMsg.createDeviceGroup(); + 2. Add device in Group -2. Add device in Group + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + registrationIDs:[ user_registration_token'], + notification_key_name:"1234_3" + notification_key:notification_key//this key is as ontained in step Create Group of Devices above -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, -registrationIDs:[ user_registration_token'], -notification_key_name:"1234_3" -notification_key:notification_key//this key is as ontained in step Create Group of Devices above + } + ) + firebaseMsg.addDeviceGroup(); -} -) -firebaseMsg.addDeviceGroup(); + 3. Delete device from Group -3. Delete device from Group + firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, + priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, + registrationIDs:[ user_registration_token'], + notification_key_name:"1234_3" + notification_key:notification_key//this key is as ontained in step Create Group of Devices above -firebaseMsg.initilize({SERVER_KEY:' YOUR_SERVER_KEY ',SENDER_ID:'YOUR_SENDER_ID',collapsible: false, -priority: 'high',contentAvailable: true,delayWhileIdle: true,timeToLive: 3,dryRun: false, -registrationIDs:[ user_registration_token'], -notification_key_name:"1234_3" -notification_key:notification_key//this key is as ontained in step Create Group of Devices above + } + ) + firebaseMsg.removeDeviceGroup(); -} -) -firebaseMsg.removeDeviceGroup(); +## License -License Copyright (C) 2018 Star labs. Licensed under the Apache License, Version 2.0 (the "License"), you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +