0

我在Parse的文檔中看到推送通知可以針對特定設備(iOS,Android等)。我想要通知iOS設備用戶使用特定的iOS(iOS 8)。這可以完成,還是僅限於針對一般設備系列?可以解析推送通知針對特定的iOS?

回答

1

您可以通過將osVersion字段添加到_Installation類中,然後對其進行查詢來完成此操作。當您保存在設備上安裝,你可以把這個字段設置\

iOS的代碼示例:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    PFInstallation *currentInstallation = [PFInstallation currentInstallation]; 
    [currentInstallation setDeviceTokenFromData:deviceToken]; 
    currentInstallation.channels = @[@"global"]; 
    currentInstallation[@"user"] = [PFUser currentUser]; 
    currentInstallation[@"osVersion"] = [UIDevice currentDevice].systemVersion; 
    [currentInstallation saveInBackground]; 
} 
+0

謝謝..所以如果用戶更改自己的iOS,安裝將重新保存,因爲應用程序將有從終止重新啓動? – SAHM 2014-10-19 02:51:15

+0

每次應用程序打開時都可以檢查是否已終止,取決於您運行代碼的位置。實際上,如果他們更新他們的操作系統,它會從終止運行。如果您想保存API調用,則只有在osVersion更改時纔可以決定重新保存。 – hybrdthry911 2014-10-19 02:55:02

+0

你怎麼知道osVersion改變了?你會將它存儲在NSUserDefaults中嗎? – SAHM 2014-10-19 03:02:11