2

ビルド中のアプリケーションがあり、Cloudkitを使用したサブスクリプションを追跡しようとしています。私は、NotificationTextと呼ばれるタイプのStringの1つのフィールドを持つNotificationsというRecordTypeを持っています。何らかの理由で、私が新しいレコードを追加すると、アプリケーションはそれを受け取らない。これまで私が行ってきたことは次のとおりです。目的C-Push通知がCloudkitと連携していない

  1. アプリの「機能」セクションにクラウドキットに登録されています。
  2. 追加使用してデータベースへのサブスクリプションを保存したリモート通知
  3. のためのInfo.plistファイルに必要なバックグラウンドモードキー:使用してプッシュ通知を送信するために、ユーザからの

    CKSubscription *subscription = [[CKSubscription alloc] 
               initWithRecordType:@"Notifications" 
               predicate:[NSPredicate predicateWithValue:YES] 
               options:CKSubscriptionOptionsFiresOnRecordCreation]; 
    
    CKNotificationInfo *notificationInfo = [CKNotificationInfo new]; 
    notificationInfo.alertLocalizationKey = @"NotificationText"; 
    notificationInfo.shouldBadge = YES; 
    notificationInfo.soundName = @""; 
    
    subscription.notificationInfo = notificationInfo; 
    [publicDB saveSubscription:subscription 
         completionHandler:^(CKSubscription *subscription, NSError *error) { 
          if (error) 
           [self handleError:error]; 
    
          [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"sub"]; 
    
         } 
    ]; 
    
  4. 要求の許可:

    UIApplication *application = [UIApplication sharedApplication]; 
    UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert categories:nil]; 
    [application registerUserNotificationSettings:notificationSettings]; 
    [application registerForRemoteNotifications]; 
    
  5. AppDelegate.mファイルで-(void)application:(UIApplication *)application didReceiveRemoteNotification:(non null NSDictionary *)userInfo fetchCompletionHandler:(non null void (^)(UIBackgroundFetchResult))completionHandler;実装されています。

私はCloudkit Dashboardに入り、RecordType Notificationsの新しいレコードを作成しますが、何も起こりません。私は何か間違っているのですか?何か不足していますか?

答えて

1

私の頭を壁にぶら下げて叩いたところ、私の問題が見つかりました。

プッシュ通知は、シミュレータでは使用しないでください!

iPodをアプリに接続して、通知が受信されました。

関連する問題