私のアプリでは、プッシュ通知の不能と許可のようなものを使用します。私はこのようなコードを使用します。また、私はsender.isOn
registerusernotificationは、unregisterForRemoteNotificationsを使用した後に動作しません。
if (sender.isOn) {
self.notificationLabel.text = @"Notifications enabled";
UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
self.notificationLabel.text = @"Notifications disabled";
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
からコードを- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
に通知をアクティブしかし、最初に使用した後unregisterForRemoteNotifications
私のアプリはregisterForRemoteNotifications
で通知をinitiallingありません。私は何が間違っているのか分かりません。