Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 85 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.