2016-04-12 18 views
-1

私はこのiOSアプリケーションを開発していますが、これは初めてGCMを処理する場所ではありませんが、このsetAllowGCMRegistrationWithoutAPNSTokenバグに直面しており、インターネット上で何かを見つけることができません。設定APNSトークンなしのGCM登録を許可する

これはTHSバグメッセージです:

"[[GGLInstanceID sharedInstance] startWithConfig:[GGLInstanceIDConfig defaultConfig]];" 

これはTHSコードです:

- (void)application:(UIApplication)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData)deviceToken { 
// [END receive_apns_token] 
// [START get_gcm_reg_token] 
// Start the GGLInstanceID shared instance with the default config and request a registration 
// token to enable reception of notifications 
[[GGLInstanceID sharedInstance] startWithConfig:[GGLInstanceIDConfig defaultConfig]]; 
_registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken, 
         kGGLInstanceIDAPNSServerTypeSandboxOption:@YES}; 
[[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:_gcmSenderID 
                scope:kGGLInstanceIDScopeGCM 
                options:_registrationOptions 
                handler:_registrationHandler]; 
// [END get_gcm_reg_token]} 
+0

コードを追加してください – iOS

答えて

0

setting up a GCM App on IOSに、このガイドに従うようにしてください。

メッセージを受信する前に、iOSアプリケーションはApple Push Notificationサービス(APN)とGCM接続サーバーの両方に登録する必要があります。クライアントアプリケーションがGCMに登録すると、登録トークンが受信され、アプリケーショントークンがAPCに送信されます(APNのデバイストークンはで、サーバーに送信されません)。クライアントアプリケーションには、登録トークンがサーバーに送信されたかどうかを示すブール値を格納する必要があります。 APNに登録し、GCM登録トークンを得るために

  1. はGCMのヘッダを含める:#import <Google/CloudMessaging.h>

  2. 登録リモート通知のためにとのAPNトークンを得ます。

  3. 設定とInstance IDを初期化し、次の引数でtokenWithAuthorizedEntity:scope:options:handler:を呼び出します。

    • アプリサーバーsender ID

    • kGGLInstanceIDScopeGCM範囲、GGLInstanceID.h

    • のAPNトークンで定義されています、オプション辞書の一部として設定され、キーはkGGLInstanceIDRegisterAPNSOptionであり、vこの値はバイナリAPNSトークン

    • に設定されています(サンドボックスの場合はYES、運用環境の場合はNO)。これはオプション辞書の一部です。

  4. トークンを取得したら、アプリケーションサーバーに送信します。あなたのバグのメッセージについては

[[GGLInstanceID sharedInstance] startWithConfig:[GGLInstanceIDConfig defaultConfig]] 

試みは

[[GGLInstanceID sharedInstance] startWithConfig:instanceIDConfig] 

チェックこのfix example of custom delegatesに置き換えることを。

関連する問題