1

Ich habe Probleme beim Generieren des Geräte-Tokens mit dem echten Gerät. Ich bin Debugger Gerät und Gerät Token wird nicht generiert. Manchmal funktioniert es und manchmal nicht.Geräte-Token, das kein iOS generiert

Bitte lassen Sie mich wissen, was Problem sein könnte. Danke

+0

Manchmal funktioniert es, manchmal nicht: Auf dem gleichen Gerät? Verschiedene Geräte? Verschiedene iOS-Versionen? Wird der Fehler Callback aufgerufen? – Larme

+0

Ich denke nicht, dass es eine gute Übung ist, dasselbe zweimal zu fragen. In beiden Fragen haben Sie keine Details, Code, iOS-Version usw. angegeben, Sie zeigen keinen Forschungsaufwand. Ich empfehle Ihnen dringend, eine Ihrer Fragen zu entfernen und so viele Details wie möglich in die von Ihnen aufbewahrte Frage aufzunehmen. Prost! –

Antwort

0

@GopalDevra könnten Sie klarer sein? Wie auch immer, ich habe diesen Code für Parse, vielleicht ist es nicht Ihr Fall, aber Sie können die Idee bekommen.

Sie können didRegisterForRemoteNotificationsWithDeviceToken in AppDelegate.m wie verwenden:

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

    // Store the deviceToken in the current installation and save it to Parse. 
    PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
    [currentInstallation setDeviceTokenFromData:deviceToken]; 
    currentInstallation.channels = @[ @"global" ]; 
    [currentInstallation saveInBackground]; 
} 

Herausgegeben

Sie dies in didFinishLaunchingWithOptions gesetzt haben?

// - Push notifications 
// -- Register for Push Notitications 
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | 
               UIUserNotificationTypeBadge | 
               UIUserNotificationTypeSound); 
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes 
                     categories:nil]; 

[application registerUserNotificationSettings:settings]; 
[application registerForRemoteNotifications]; 

//-- Set Notification 
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
{ 
    // iOS 8 Notifications 
    [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 

    [application registerForRemoteNotifications]; 
} 
else 
{ 
    // iOS < 8 Notifications 
    [application registerForRemoteNotificationTypes: 
    (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];   
} 

//--- your custom code 
+0

Vielen Dank Ich habe diese Codezeilen ausprobiert. Aber funktioniert nicht –

+0

@GopalDevra Ich aktualisierte meine Antwort. Hör zu. –

+0

@ J.Lopes Können Sie heute einen Geräte-Token von Sandbox APN bekommen? –

1

Haben setzen Sie unten in didFinishLaunchingWithOptions von AppDelegate.m?

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) 
{ 
    NSLog(@"ios8 app"); 
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 
    [[UIApplication sharedApplication] registerForRemoteNotifications]; 
} 
else 
{ 
    NSLog(@"lower ios8 app"); 
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; 
} 
0

diese Methode hinzufügen,

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) 
    { 
     print("application:didFailToRegisterForRemoteNotificationsWithError: %@", error) 
    } 

Sie Antwort bekommen, warum Token nicht generiert wird.

+0

Edit für objective c :-(void) Anwendung: (UIApplication *) Anwendung didFailToRegisterForRemoteNotificationsWithError: (NSError *) Fehler { } –

1

Ab sofort habe ich auch Probleme, Gerätemarken zu bekommen.

Meine Projekte haben die Generierung von Tokens für Geräte gestoppt, als sie vor ungefähr 10 Stunden "gelöscht" und "installiert" wurden. Auch im koreanischen iOS-Entwicklerforum haben einige Leute Probleme mit APNS-Tokens gemeldet, die in den letzten 10 Stunden nicht generiert wurden.

Möglicherweise stimmt etwas mit einigen der Sandbox APNS-Server nicht.

  • Zuletzt überprüft Zeit 2016.04.27 22.43 Uhr 0900 GMT: Kein Gerät Token, Push-Benachrichtigung nicht angekommen.
+0

ist das wirklich passiert @ CheeseLemon? –

+0

Ja, jetzt meldet sich jeder, jetzt funktioniert es wieder. – CheeseLemon

Verwandte Themen