9

Ich versuche, ein gcm Thema auf iOS zu abonnieren.Gcm iOS, abonnieren Thema, Fehlercode 3004

GCMPubSub.sharedInstance().subscribeWithToken(registrationId, topic: "/topics/mytopic", options: nil) { error in 
    print(error.localizedDescription) 
} 

Der Vorgang konnte nicht abgeschlossen werden. (com.google.gcm Fehler 3004.)

Ich kann nirgendwo eine Dokumentation für diesen Fehlercode finden. Ich habe auch gelesen, den Quellcode, wo die Fehler definiert sind, und es sieht wie folgt aus:

typedef NS_ENUM(NSUInteger, GCMServiceErrorCode) { 
    /** 
    * HTTP errors. 
    */ 

    // InvalidRequest -- Some parameters of the request were invalid. 
    kGCMServiceErrorCodeInvalidRequest = 0, 

    // Auth Error -- GCM couldn't validate request from this client. 
    kGCMServiceErrorCodeAuthentication = 1, 

    // NoAccess -- InstanceID service cannot be accessed. 
    kGCMServiceErrorCodeNoAccess = 2, 

    // Timeout -- Request to InstanceID backend timed out. 
    kGCMServiceErrorCodeTimeout = 3, 

    // Network -- No network available to reach the servers. 
    kGCMServiceErrorCodeNetwork = 4, 

    // OperationInProgress -- Another similar operation in progress, 
    // bailing this one. 
    kGCMServiceErrorCodeOperationInProgress = 5, 

    // Unknown error. 
    kGCMServiceErrorCodeUnknown = 7, 

    /** 
    * Upstream Send errors 
    */ 

    // Upstream send not available (e.g. network issues) 
    kGCMServiceErrorCodeUpstreamServiceNotAvailable = 1001, 

    // Invalid send parameters. 
    kGCMServiceErrorCodeInvalidParameters = 1002, 

    // Invalid missing to. 
    kGCMServiceErrorCodeMissingTo = 1003, 

    // GCM could not cache the message for sending. 
    kGCMServiceErrorSave = 1004, 

    // Message size exceeded (size > 4KB). 
    kGCMServiceErrorSizeExceeded = 1005, 

    /** 
    * GCM Connect errors. 
    */ 

    // GCM already connected with the client. 
    kGCMServiceErrorCodeAlreadyConnected = 2001, 

    /** 
    * PubSub errors. 
    */ 

    // Topic already subscribed to. 
    kGCMServiceErrorCodePubSubAlreadySubscribed = 3001, 

    // Topic already unsubscribed from. 
    kGCMServiceErrorCodePubSubAlreadyUnsubscribed = 3002, 

    // Invalid topic name, does not match the topic regex "/topics/[a-zA-Z0-9-_.~%]+" 
    kGCMServiceErrorCodePubSubInvalidTopic = 3003, 
}; 

Fehlercodes bei 3003 enden!

Antwort

6

Ich habe das schon einmal gesehen, weil ich GCM vor der Verwendung von GCMPubSub nicht gestartet habe. So sollte dies beheben für Sie

var config = GCMConfig.defaultConfig() 
// Note you should only call start once during the lifetime of your app. 
GCMService.sharedInstance().startWithConfig(config) 
GCMPubSub.sharedInstance().subscribeWithToken(registrationId, topic: "/topics/mytopic", options: nil) { error in 
    print(error.localizedDescription) 
} 
+0

das war, was ich verpasst. Danke vielmals! – Siamaster

+0

Ich habe auch dieses Problem und das hat meinen Fehlercode 3004 – oronbz

+0

nicht gelöst, danke! Hinweis an alle, die "GCMService" und "GGLInstanceID" nicht beachten: die beiden sind anders! – wangii

1

Das Problem für mich war, dass man nicht einmal GCMPubSub.sharedInstance() nennen können, bis Sie GCMService.sharedInstance().startWithConfig(config) nennen so können Sie nicht GCMPubSub.shareInstance() als Eigenschaft speichern, bevor sie tatsächlich Aufruf subscribeWithToken

Verwandte Themen