Description
On iOS 13 registering for push notifications returns an invalid device token, this is because the way we decode the device token has been broken by apple (although it seems it wasnt a recommended way anyways)
See
https://github.com/OneSignal/OneSignal-iOS-SDK/pull/509
Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
// Remove event listener once registered for push notifications
Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);
Ti.Network.registerForPushNotifications({
success: deviceTokenSuccess,
error: deviceTokenError,
callback: receivePush
});
});
// Register notification types to use
Ti.App.iOS.registerUserNotificationSettings({
types: [
Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
]
});
// Process incoming push notifications
function receivePush(e) {
alert('Received push: ' + JSON.stringify(e));
}
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
console.log('Yay it worked!');
console.log(e);
}
function deviceTokenError(e) {
console.log('Failed to register for push notifications! ' + e.error);
console.log(e);
}
Steps to reproduce
1. Add the below code to an app.js or alloy.js
Actual
The device token printed looks like
{length=32,bytes=0x17b4427542a3d1e6a4d69d976b4539bc...7edb18a21200a8d2}
Expected
The device token should look like
17b4427542a3d1e6a4d69d976b4539bcf227f216b02b5fd97edb18a21200a8d2
master: https://github.com/appcelerator/titanium_mobile/pull/11202 8_2_X: https://github.com/appcelerator/titanium_mobile/pull/11203
fixed 8_2_X PR: https://github.com/appcelerator/titanium_mobile/pull/11207
FR Passed. Waiting on Jenkins builds for Master and 8_2_X.
master PR was already merged. Merged 8_2_X PR.
Closing ticket. Fix verified in SDK version
8.2.0.v20190912104344
and SDK version8.3.0.v20190913104800
. Test and other information can be found at: master: https://github.com/appcelerator/titanium_mobile/pull/11202 8_2_X: https://github.com/appcelerator/titanium_mobile/pull/11203