IOS GCM GCMPubSub Unsubscribe error 7 - Unknown error

For GCM topic messaging, trying to unsubscribe from a topic I get the following in my log (see code below)

Failed to unsubscribe from topic /topics/testTopicName: Error Domain=com.google.gcm Code=7 "The operation couldn’t be completed. (com.google.gcm error 7.)"

      

Now I can subscribe to a topic with the same registration token, and also receive up-to-date posts for that topic, but I cannot unsubscribe from it. I get this every time I try to unsubscribe. According to Google , "7" - "unknown error" - great ...

I have observed the same behavior for all themes I have created so far.

+ (void)unsubscribeFromGCMTopic:(NSString*)topicName
{
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];

// If the app has a registration token and is connected to GCM, proceed to unsubscribe from the
// topic
if (app.registrationToken && app.connectedToGCM)
{
    NSString* topic = [NSString stringWithFormat:@"%@%@", TOPIC_PREFIX, topicName];

    [[GCMPubSub sharedInstance] unsubscribeWithToken:app.registrationToken
                                               topic:topic
                                             options:nil
                                             handler:^void(NSError *error)
                                             {
                                                 if (error)
                                                 {
                                                     NSLog(@"Failed to unsubscribe from topic %@: %@", topic, error);                                                        
                                                 }
                                                 else
                                                 {
                                                     // Unsubscribe successfully
                                                     NSLog(@"Successfully unsubscribe from topic %@", topic);
                                                 }
                                             }];
}
else
{
    NSLog(@"Cannot GCM unsubscribe from %@. Token %@. GCM connection status %d", topicName, app.registrationToken, app.connectedToGCM);
}
}

      

Any ideas? Thanks in advance!

+3


source to share


1 answer


validate application delegate when using sandbox or product kGGLInstanceIDAPNSServerTypeSandboxOption: true]

for production:

 //RECEBE DADOS CERTIFICADOS_APNS_TOKENS
func application( application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken
    deviceToken: NSData ) {
        let instanceIDConfig = GGLInstanceIDConfig.defaultConfig()
        instanceIDConfig.delegate = self

        print("\nDEVICE: \(deviceToken)\n")


        //PARA TESTAR NOTIFICACAO COLOCAR SANDBOX COMO TRUE e para PRODUCAO COLOCAR COMO FALSE
        GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig)
        registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:false]
        GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID, scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)

}

      



to check using true:

 //RECEBE DADOS CERTIFICADOS_APNS_TOKENS
func application( application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken
    deviceToken: NSData ) {
        let instanceIDConfig = GGLInstanceIDConfig.defaultConfig()
        instanceIDConfig.delegate = self

        print("\nDEVICE: \(deviceToken)\n")


        //PARA TESTAR NOTIFICACAO COLOCAR SANDBOX COMO TRUE e para PRODUCAO COLOCAR COMO FALSE
        GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig)
        registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:true]
        GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID, scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)

}

      

0


source







All Articles