RegisterPushNotificationDeviceToken
Registers the given device token from the server to enable this device to receive push notifications.
| Service | Operation |
|---|---|
| pushNotification | REGISTER |
Method Parameters
| Parameter | Description |
|---|---|
| platform | The device platform being registered. |
| token | The platform-dependant device token needed for push notifications. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
Platform deviceType = Platform.iOS;
string deviceToken = "12345";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.PushNotificationService.RegisterPushNotificationDeviceToken(deviceType, deviceToken, successCallback, failureCallback);
Platform deviceType = Platform::iOS;
const char *deviceToken = "12345";
_bc->getPushNotificationService()->registerPushNotificationDeviceToken(deviceType, deviceToken, this);
PlatformObjc *deviceType = [PlatformObjc iOS];
NSString *deviceToken = @"12345";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc pushNotificationService] registerPushNotificationDeviceToken:deviceType
deviceToken:deviceToken
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
Platform deviceType = Platform.iOS;
String deviceToken = "12345";
this; // implements IServerCallback
_bc.getPushNotificationService().registerPushNotificationDeviceToken(deviceType, deviceToken, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var deviceType = "IOS";
var deviceToken = "12345";
_bc.pushNotification.registerPushNotificationToken(deviceType, deviceToken, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var devicePlatform = PlatformID.iOS;
var deviceToken = "12345";
ServerResponse result = await _bc.pushNotificationService.registerPushNotificationToken(platform:devicePlatform, deviceToken:deviceToken);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var deviceType = "IOS";
var deviceToken = "12345";
var pushNotificationProxy = bridge.getPushNotificationServiceProxy();
var postResult = pushNotificationProxy.registerPushNotificationDeviceToken(deviceType, deviceToken);
if (postResult.status == 200) {
// Success!
}
{
"service": "pushNotification",
"operation": "REGISTER",
"data": {
"deviceType": "IOS",
"deviceToken": "12345"
}
}
JSON Response
{
"status": 200,
"data": null
}