@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
Manchmal funktioniert es, manchmal nicht: Auf dem gleichen Gerät? Verschiedene Geräte? Verschiedene iOS-Versionen? Wird der Fehler Callback aufgerufen? – Larme
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! –