[英]didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios 9
[英]IOS 11 didRegisterForRemoteNotificationsWithDeviceToken not called
調用registerForRemoteNotifications之后,未調用appDelegate方法didRegisterForRemoteNotificationsWithDeviceToken。 我沒有收到來自APN的令牌,因此無法收到推送通知。
我看到“允許”彈出,但是在選擇允許之后,我沒有從didRegisterForRemoteNotificationsWithDeviceToken得到通常的響應。
一切都可以在IOS 11之前運行。
還有其他人遇到同樣的問題嗎? 關於我的問題似乎沒有很多抱怨。
對於APNs注冊過程,IOS 11中是否有任何更改? 當應用程序在后台運行時,IOS 10中的didReceiveRemoteNotification也無法正常工作。
Ive在上下搜索了一個修復程序,但是對於IOS 11,推送通知對我而言只是一頭霧水。
我已經正確設置了所有Info.plist數據。 我在項目設置中設置了所有開關。 我已經測試了我們應用的早期版本。 我創建了一個簡單的項目,就像我們的生產應用程序一樣,它也不起作用。 我假設注冊代碼與IOS 10相同。
求救! 謝謝。
在AppDelegate
類方法didFinishLaunchingWithOptions
您必須使用代碼-
if( SYSTEM_VERSION_LESS_THAN( @"10.0" ) )
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
if( optind != nil )
{
NSLog( @"registerForPushWithOptions:" );
}
}
else
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if( !error )
{
[[UIApplication sharedApplication] registerForRemoteNotifications]; // required to get the app to do anything at all about push notifications
NSLog( @"Push registration success." );
}
else
{
NSLog( @"Push registration FAILED" );
NSLog( @"ERROR: %@ - %@", error.localizedFailureReason, error.localizedDescription );
NSLog( @"SUGGESTIONS: %@ - %@", error.localizedRecoveryOptions, error.localizedRecoverySuggestion );
}
}];
}
並添加以下framework
-
我也嘗試過此解決方案,但沒有成功。
我們的團隊實際上解決了這個問題。 團隊成員注意到didRegisterForRemoteNotificationsWithDeviceToken正在使用Xcode 9和IOS 11。
只需將我的iPhone 6s plus設備插入計算機並運行該應用程序,問題就消失了。
設備現在接收didRegisterForRemoteNotificationsWithDeviceToken。
我把這歸因於一些IOS更新的怪異之處。
謝謝你的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.