有人建议我应该允许用户在我的应用程序中打开和关闭推送通知。我正在使用 Parse 来管理我的推送通知。我已经完成了所有设置,以便用户可以通过按“允许”来注册通知。当推送警报弹出时。不过,我的问题是,如果用户最初说“不允许”,我将如何允许用户从应用程序内打开推送通知。我知道推送通知警报只会显示一次。有没有人有任何想法?谢谢!
我的应用代表:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions {
[Parse setApplicationId:@"APP_ID"
clientKey:@"CLIENT_KEY"];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
//other code
}
- (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 saveInBackground];
}
用户设置视图控制器:
-(IBAction) switchValueChanged {
if (toggleSwitch.on) {
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
else {
}
}