2013-06-22 28 views
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 { 

    } 
} 

回答

1

你不能做到這一點。用戶必須手動進入通知設置併爲您的應用設置通知。顯然原因是蘋果公司不希望一個應用程序糾纏用戶,如果用戶已經說過沒有一次。

我建議讓您的應用程序顯示一條警告,以通知用戶打開通知。