0
我被告知我應該允許用戶在我的應用內啓用和關閉推送通知。我正在使用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 {
}
}