In order to schedule push notifications to your users’ devices, their devices need to be subscribed into the system. You can apply the following JavaScript code in your web app page, with this, the device will be automatically subscribed to the system when your users access to this web app page.
OR, you can manually subscribe the user’s device using our API service if you already know the user’s device UUID and device token. Scroll further down to know the steps to connect with our API service.
JavaScript code example
<script>
jQuery(function($){
var web_data = [{
"type": "subscribe",
"data": {
"api": "your-api-key",
"url": "https://centrecbiz.com/subscribe_device.php",
"category": "category-name",
"user": "user-unique-id",
},
}];
window.top.ReactNativeWebView?.postMessage(JSON.stringify(web_data));
});
</script>
- your-api-key: Get your unique API key in your account dashboard (My Account) after subscribing our Web to App package. You need to keep your subscription active in order to use the API key.
- category-name: Categorise your users using a special category name.
- user-unique-id: Put in the user’s ID so that you are able to map the user to his or her device and send them notifications correctly.
API example
Submit request to the following URL together with the required URL parameters
https://centrecbiz.com/subscribe_device.php
//URL Parameters
rest_api_key=your-api-key
device_uuid=user-device-uuid
device_token=user-device-token
user_id=user-unique-id
subscription=category-name
Sample Return Results
{"code":"1","msg":"Success!"}
- code: 1 indicates request success while 0 indicates request failed.
- msg: Specify success or the reason of failure.