Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27386

iOS: Correctly decode push notification token

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 8.2.0, Release 8.1.1
    • Fix Version/s: Release 8.2.0
    • Component/s: iOS
    • Labels:
    • Environment:

      SDK: 8.2.0.v20190906153418
      iOS 13

    • Story Points:
      3
    • Sprint:
      2019 Sprint 18, 2019 Sprint 19

      Description

      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
      

        Attachments

          Activity

            People

            • Assignee:
              eharris Ewan Harris
              Reporter:
              eharris Ewan Harris
              Reviewer:
              Vijay Singh
              Tester:
              Samir Mohammed
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code