When install build from xcode push notification is working but when install ipa it is not working

前端 未结 5 771
梦毁少年i
梦毁少年i 2021-01-19 03:39

I implemented push notification in my app and it is working when i install build from xcode but not working when i install app via a link generated by diawi.com why this is

5条回答
  •  独厮守ぢ
    2021-01-19 04:08

    Late to this question, but had a similar troubled experienced so thought I'd share. As @sadiqxs noted:

    • if you install from xcode - It uses development certificate

    • if install from diawi.com - It uses production certificate

    This forms a big problem when you try to debug remote notifications. However, there is a simple workaround! The trick is to install an AdHoc build once, which will register the phone using the productions certificate. Then add the following block around your register method (the place in the code where you decided to register a user for notfications).

    #ifndef DEBUG 
    
    //your code to register for notifications, something along the lines of
        UIApplication* application = [UIApplication sharedApplication];
    
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    
    #endif
    

    What this will do, is skip the register statement when you run the app on consecutive builds through XCode and thus keep production notifications from coming in!

    Hope this helps

提交回复
热议问题