簡體   English   中英

設備在Apple推送通知中使用令牌注冊,但不接收來自服務器的通知

[英]Devices are registered with token in Apple Push Notification but don't receive notifications from the server

在我的應用程序中,我有以下APN進程:

  • didFinishLaunchingWithOptions中注冊設備;
  • 使用didRegisterForRemoteNotificationsWithDeviceToken接收令牌;
  • 將其發送到我的通知服務器;
  • 我的服務器發送通知;
  • 問題:我的設備沒有收到它( didReceiveRemoteNotification從未調用Debug);

已經檢查了服務器和證書上的App Id。

任何人都可以指出我做錯了什么?


AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Checking if app is running iOS 8
    if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
        // Register device for iOS8
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings
                settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge |
                        UIUserNotificationTypeSound categories:nil];
        [application registerUserNotificationSettings:notificationSettings];
        [application registerForRemoteNotifications];
    } else {
        // Register device for iOS7
        [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert |
                UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge];
    }

    //...

    return YES;
}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    NSLog(@"Registration successful, bundle identifier: %@, device token: %@",
            [NSBundle.mainBundle bundleIdentifier], deviceToken);

    // Receive the token and send it to my Server
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
    NSLog(@"Error in registration. Error: %@", err);
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

    // Handle notification
}

LefterisRajat是對的,我的問題是環境的錯誤證書。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM