您如何使用 parse 将用户从接收推送通知中移除?例如,如果用户转到他的设置(在应用程序内)并决定关闭推送通知...
我认为删除他们的“全局” channel 就可以解决问题,但用户似乎仍在使用它们。想想看,如果这确实有效,他们仍然能够将推送发送到与用户关联的其他 channel 。无论如何,解决这个问题的方法是什么?
我尝试过这两种方法:
currentInstallation.channels = @[ @"global" ]; //enable
currentInstallation.channels = @[]; //disable
和
[currentInstallation addUniqueObject:@"global" forKey:@"channels"]; //enable
[currentInstallation removeObject:@"global" forKey:@"channels"]; //disable
然后我尝试通过 Parses Web UI 为“每个人”发送一个推送,并且只为那些匹配“全局” channel 的人发送一个推送。不幸的是,用户仍然收到了它。
我几乎遵循了 Parse iOS 推送设置教程。这就是我的实现的样子:
-(void)displayPushAuthRequest{
UIApplication *app = [UIApplication sharedApplication];
if([app respondsToSelector:@selector(registerUserNotificationSettings:)] && [app respondsToSelector:@selector(registerForRemoteNotifications)]){
//ios 8
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
{
//ios 7
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Save the settings locally (first time)
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"didRegisterForRemoteNotifications"];
[[NSUserDefaults standardUserDefaults]synchronize];
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"global" ];
[currentInstallation saveInBackground];
}
最佳答案
你可以试试下面的方法吗
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.channels = [NSArray array];
[currentInstallation saveEventually];
关于ios - 在 Parse 上删除用户推送通知 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28948973/