Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24087] iOS: Ti.Network.registerForPushNotifications does not call callbacks on iOS 10

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-11-08T10:15:18.000+0000
Affected Version/sRelease 5.5.1
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMike Neill
AssigneeVijay Singh
Created2016-10-30T10:36:47.000+0000
Updated2017-03-31T22:36:30.000+0000

Description

My application has been using the same code to register for push notifications for several quite a while now, and has been working perfectly the entire time. However, suddenly now after I update my device to iOS 10 and try to register the aforementioned function will not call any of the callbacks. The success, failure or push callbacks are called. I am not sure what is going on, but I do know my code has not been modified, so this is strange. When the application launches for the first time I do get the dialog from iOS requesting permission for notifications, and I am pressing allow. I have also double checked on my device to ensure that notification are enabled for my application. I have tried in both debug and release configurations. Any suggestions or help would be greatly appreciated it. Here is my code.
Ti.App.iOS.addEventListener('usernotificationsettings', e = function(v) {
                
    console.log("In usernotificationsettings: " + JSON.stringify(v));
    
    Ti.App.iOS.removeEventListener('usernotificationsettings', e);
    Ti.Network.registerForPushNotifications({
        success: onSuccess,
        error: deviceTokenError,
        callback: receivePush
    });
});

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
    ]
});

var onSuccess = function(e) {
            
    console.log("TOKEN: " + e.deviceToken);
    
    // do stuff
};

var receivePush = function(e) {
    console.log('Received push: ' + JSON.stringify(e));
};

var deviceTokenError = function(e) {
    console.log('Failed to register for push notifications! ' + e.error);
};
In tiapp.xml file I have the following keys for background modes.
<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
    <string>remote-notification</string>
</array>

Attachments

FileDateSize
PushNotificationDemo.zip2016-11-03T10:05:20.000+000063398
test_push.zip2016-11-08T09:54:59.000+000010314285

Comments

  1. Hans Knöchel 2016-10-30

    Please ensure that you use provisioning profiles that have the correct entitlements enabled and the certificate is not expired or managed. Also I know that Xcode 8 does not grab the aps-environment from the provisioning profile anymore, so ensure you use 5.5.1.GA SDK *and* CLI or add the aps-environment either to development or production manually. Finally, see TIMOB-23908 and TIDOC-2679 for similar discussions.
  2. Mike Neill 2016-10-31

    Hi, I have updated to the 5.5.1 GA SDK and no change. I have also ensured that my provisioning profiles are valid, and not managed which shouldn't matter to be honest as the app ID is what is tied to the push notification entitlement and even managed profiles will be hooked into the correct app ID. Finally, I have also ensured that my application does have an entitlements file with the following keys. aps-environment development I don't believe any of what you mentioned, maybe expect for the SDK, could have possibly caused this issue as the OS is still requesting permissions. In my experience doing native iOS applications you will not received the permission request dialog if the application is not setup correctly for push notifications and/or if the entitlements file is not correct. There seems to be something fundamentally wrong with the Appcelerator implementation and this needs to be investigated and resolved ASAP as it's causing me to not be able to send out builds to my clients.
  3. Hans Knöchel 2016-10-31

    [~ewieber] is investigating the issue this week, he will update this ticket. But as my internal tests for TIMOB-23527 all worked, I have a feeling something is invalid with your environment.
  4. Mike Neill 2016-11-01

    Ok, it's good someone is going to look into it, but again I must say I highly doubt it's my setup. Push notifications had been working in this app until I updated my device to iOS 10. Considering that was the only difference, and the fact that no callbacks are called at all, tells me something must be wrong with the Titanium implementation. Even if my setup is somehow wrong I would expect an error message in the console log at the very least that can help to clearly identify the issue.
  5. Hans Knöchel 2016-11-01

    Yes.I also found http://stackoverflow.com/questions/38940193/handling-user-notifications-on-ios-10 which shows a possible native issue. Please try to use 10.1 and report back. If that works again (as said in the ticket), we will apply the suggested patch for iOS 10.0 (since 9.x and 10.1+ would not be affected).
  6. Hans Knöchel 2016-11-01

    Hey Neill, I just tested it on my iOS 10.1 device using Xcode 8.1 and Titanium SDK 5.5.1.GA and the "Pusher" app to send remote notifications from my Mac: - The push auth dialog appeared - After accepting pushed, the success callback with the UUID was thrown - The UUID was used in Pusher and the notification arrived (both normal notification and interactive notification) *Sample App*: https://www.dropbox.com/s/qxronmx7eor5ohe/testapp_push.zip?dl=0 *NOTE*: I do not have any custom entitlements in my app, since all push-related things are generated by the CLI. As I don't have a 10.0 device here, I hope [~ewieber] has to confirm. If it works there as well, we will resolve this issue as "Not Reproducible", otherwise we will apply the above patch. Thx!
  7. Vijay Singh 2016-11-03

    Hi Hans, I have verified the SDK for push notification using the code shared by you. And I tested the push notification using sample app "PushNotificationDemo.zip" as attached. This was done in iOS 10.0.2 and iOS 10.1.1. My findings are as below for both iOS- Using SDK - 1. The push dialogue appeared . 2. On selecting "Allow", I didn't get call back for device token . Using Native App - 1. The push dialogue appeared . 2. On selecting "Allow", I get call back for device token . Result - It looks the issue is not with iOS version probably with SDK. Though I am surprised that it is working on your side for SDK. (I am using latest code of SDK ) Will look in code of SDK to analyze more .
  8. Vijay Singh 2016-11-04

    PR(master) : https://github.com/appcelerator/titanium_mobile/pull/8584
  9. Hans Knöchel 2016-11-07

    As said in the ticket, the issue Vijay had was that he tested from the debug Xcode project and the define-flag was not defined there. So it won't have any effect on device builds. But as it worked for him after adding it, it means that the core itself works as fine as for me. He will update this ticket with his findings using a compiled SDK version soon, but this still looks invalid for me.
  10. Vijay Singh 2016-11-08

    I created a sample project using Appcelerator studio , and verified the same on iOS 10.0.2 . It is working properly .
  11. Mike Neill 2016-11-08

    In the original issue I noted that the problem was with 10.1. When my device was at 10.0.1 and 10.0.2 everything worked correctly. I'd recommend testing against that version of iOS as something is absolutely wrong.
  12. Hans Knöchel 2016-11-08

    [~miken01] I tested with iOS 10.1 and even iOS 10.2, it works as expected for all of our tests. So if you can provide a reproducible test-project (the one the sent cannot be reproduced), please feel free to provide it here, otherwise we have to resolve it as "Cannot Reproduce". *EDIT*: And I just attached test_push.zip for our test-case and [this image](https://abload.de/img/unknowneys8g.png) to see that the token is received properly.
  13. Mike Neill 2016-11-08

    Ok, it's possible that maybe the debug flag that you all mentioned above may have not been set, but during my tests it wasn't working for debug nor release builds. Maybe I'm wrong for thinking this, but if it doesn't work on a release build then a debug flag wouldn't matter at all right? To be honest it's not worth my time to pull the code out into a separate project. I have already advised my client to go away from Appcelerator and go fully native as there are several features of their product we're not able to implement with this framework. I've also found several bugs over the last few months that I have reported here. Personally, I do feel this is a bug somewhere in the SDK as I've setup push notifications on native apps for years and not once have ever had a problem with my setup. Furthermore, push notifications were working 100% correctly until I updated my device to 10.1. Perhaps the issue is with my device alone, but I doubt it. Anyways, I appreciate the time you guys have put into this, but at this time it's just more cost effective for me to move to a native platform. Thanks!
  14. Hans Knöchel 2016-11-08

  15. Mike Neill 2016-11-08

    Hi Hans, Please bear in mind that our decision to move away from Appcelerator wasn't one of haste. I've done my best to fix this application the best I could using this tool, but many issues remain. Yes, you all have invalidated some of my issues which I believe is simply because you couldn't replicate the issues. Just because you're not able to replicate a bug doesn't mean it doesn't exist. However, as an engineer myself I understand it's impossible to fix a bug you can't replicate, so no qualms there. I could go on with the laundry list of issues I have on a day-to-day with Appcelerator such as but not limited to the debugger tends to take a very long time to connect to Appcelerator Studio if at all. The fact that debug builds tend to not work when Appcelerator isn't running as they should. The fact that every time I've upgraded the SDK version of Titanium I am using I get crashes left and right, and not to mention that I can't even create a breakpoint in my main JavaScript files. Who in their right mind is going to go into their build directory, load up a built version of the JavaScript file, and then place a breakpoint. That's horrible workflow for debugging and should be corrected to work within the original file. I could go on and tell you that it's horrifying to find in a release build that some people's devices will load the AppIcon while others won't. It seems to be purely the luck of the draw. Unfortunately, I simply do not have time to note every single issue I've ever had with this platform, and I've only been using it for a few months. The main problem with this product in my opinion it's based on JavaScript. A language that was devised in about 10 days by Brendan Eich. Guy is an awesome engineer, but the entire language was written in 10 days. It doesn't even have a concept of integer values. Yet, this isn't a comment on the shortcomings of the language. I'm simply stating that when you build a house on a pile of sticks, then it's going to crumble at the first storm. Which Appcelerator has time and time again. I will say that Appcelerator has great customer service and tech support. I believe you all are truly wanting to help me out, and I believe you cannot replicate the errors. However, that doesn't mean that their nonexistent. Considering everything was hunky dory a few weeks ago before iOS 10.2, Xcode 8.1 and of course the latest offering from the Titanium SDK I have to believe something is wrong with the tech stack and not the code. Especially, considering I pulled it from your own documentation just last week. And yes my app ID has the push notification entitlement, my app has Background Modes enable and does have the remote notifications key as I showed above. In an native app this is all I would need and it would just work. I do appreciate the help guys, and I hope you all have a good day.
  16. Lee Morris 2017-03-31

    Unable to reproduce this issue, tested with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80 Please file a new ticket if this problem still persists.

JSON Source