앱 사용자는 버튼을 켜거나 끔으로써 원격 알림을 사용/사용 중지 할 수 있어야합니다.원격 알림 사용 및 사용 안함
"didFinishLaunchingWithOptions"의 원격 알림 용 앱 등록자입니다. 사용자가 버튼을 클릭하면 원격 알림을 해제하는 코드는이 작동
// Register for Push Notifications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType userNotificationTypes = UIUserNotificationTypeNone;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
}
else
{
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeNone];
}
입니다. 원격 알림이 사용 중지되었습니다.
그러나 사용자가 클릭 다시 원격 통지
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
{
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
UIUserNotificationSettings * settingsAvailable = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settingsAvailable];
[application registerForRemoteNotifications];
}
else
{
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
앱이 유형 (경고, 배지 또는 소리)
어떤 조언 아무도 등록하지 않습니다를 사용하는 경우? 미리 감사드립니다.
나는 그것을 시도했다. 매번 버튼이 켜지거나 꺼질 때마다 userDefault에이 옵션을 저장하고 AppDelegate "didReceivePushNotifications"에서 푸시 알림을받지 못하게하려고하지만 원격 알림이 여전히 전화로 수신되는 이유는 모르겠다. – Developer3000
당신이하고있는 일이 의미가 있습니다. ** didReceiveRemoteNotification **이 호출되면 이미 너무 늦었습니다. 푸시가 이미 보내지고 수신되었으며 사용자가 보았을 것입니다. 앞에서 말한 것처럼 사용자 환경 설정을 직접 확인하고 환경 설정에 따라 푸시 알림을 보내거나 보내지 않아야합니다. – stromdotcom
아마도 당신이 옳고 그렇게하는 가장 좋은 방법이어야합니다. 고맙습니다 . – Developer3000