Closed enda closed 8 years ago
Hi,
Push token is the same as deviceToken
The deviceToken is an UUID giving by the device, instead of pushToken which is a string giving by GCM or APNS, so the pushToken can change depending on the app you are, and not the deviceToken.
The documentation here http://docs.pushwoosh.com/docs/registerdevice of registering a device need a push_token, and a hwid (deviceToken), so nope, they are logically not the same, and even if, the API should return the same type of object independently of the OS.
deviceToken is push token, see: https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/master/src/ios/PushNotification.m#L180
To get UUID check this method: https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/master/src/ios/PushNotification.m#L46
Hello @shaders,
thanks for the details, I now better understand the difference.
So maybe the bug is only that the result of the method registerDefice of the API between iOS and Android are different ? (an object in one side, and a string in the other one).
In my way, I will fix it by testing if my result is of type string or object, but it don't look natural...
Thanks,
Jerome
You are right, iOS and Android return different values here. I agree they should return values the same way, I'll put this into the backlog.
+1 :D Needed here too
Fixed in 6.0.0
Hola!
I recently included the Pushwoosh plugin with ionic plugin add pushwoosh-cordova-plugin
And it installed version 5.1.3. I came across the problem above and handled the callback as per device type.
pushwoosh.registerDevice(
function(status) {
var pushToken;
if(ionic.Platform.isIOS()) {
pushToken = status.deviceToken;
// ...
} else if(ionic.Platform.isAndroid()) {
pushToken = status.split(':');
pushToken = (pushToken.length > 1) ? pushToken[1] : null;
// ...
}
},
function(error) {
// What happens on error?
console.error(error);
}
);
How would I know if I should use 6.0.0 now and if it is stable?
I am just unsure now if I should try it again with the newer version.
Thanks for an oppinion! ✌️
Push notification token is passed as status.pushToken
in registerDevice success callback for all platforms since 6.0.0. Please check the new documentation and sample code.
Hello guys,
When I do a simple
registerDevice(function(data) { console.log(data); });
, on Android I get a correct push token, but not on iOS where I get an object like that:and no push token :(
How can I get one on both device ?