iOS8 下 Push Notification 推播服務的改變

2014/09/14
~ 阿亮 ~

今天 (2014/09/14) 用 Xcode5.1.1. 產生的批踢踢快訊 iOS v1.7.0  被 REJECT 了,因為 CRASH 了,根據 apple 提供的 crash report file 顯示,這是 iOS8 下造成的,還真不知在 Xcode5.1.1 編譯的也會被測試 iOS8 下的運作,只好實機灌灌 iOS8 GM Seed 測試測試了。

測試過程中,發現有以下的錯誤訊息:

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

 

這時候才發現 iOS8 下的推播改版了,改成所謂的互動式推播 ,即接收推播後,在推播的項目即可直接回覆、動作,不用進入 app 才能動作了;另外,在設定方面也不太一樣了,在 iOS7 下是「設定」>「通知中心」>「應用程式」去設定是否開關通知的設定,現在「設定」下即會有該應用程式,點入應用程式以進入推播設定,如下圖,左邊是 iOS7 例子,右邊是 iOS8 的例子。
0914_002

 

前面講的 registerForRemoteNotificationTypes 問題,則要用以下這段程式碼來支援 iOS8 的推播啟始註冊

// Set Notification
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings 
     settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)      
categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

 

然後,以下原本在 iOS7 可以用在判斷是否推播有打開的程式

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
return (types & UIRemoteNotificationTypeAlert);

會出現以下的錯誤訊息,不一定會當掉,但功能至少會被忽略.

 enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.

 

這段要改由 currentUserNotificationSettings 去取得 types,所以這段程式碼要用以下這段取代.

UIRemoteNotificationType types;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
else
    types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

return (types & UIRemoteNotificationTypeAlert);

 

 
2014.10.02 發現在送審 每日新聞快訊 iOS v1.3.2  時,發現舊有的 Distribution Certificate 可能會有 Missing Push Notification Entitlement 的訊息,這個需要去 Developer Portal 去重新 Generate Provision Profile,下載它後,點擊它安裝後,才能再產生出有 aps-environment production 的 Entitlement。

1002_002

這時應該在 Xcode 內原本的 Distribution Certificate 變成字串失效了,再重新指定它。

1002_003

在 Validate/Submit 前,這時檢查 aps-environment production,該 entitlement 這時應該就有出現了!

 
 



2 Responses to “iOS8 下 Push Notification 推播服務的改變”

站內搜尋



本站其他服務

本站其他軟體



  • 下一台單車(NextBike)

    打開定位即搜尋附近二十點自行車站點,不塞滿全部站點資料到整個地圖上,所以畫面簡潔方便看清楚目前所在地,若需要搜尋地圖其他位置附近站點,再點擊地圖即可。


  • 台灣匯率快算

    提供全球 150 種以上貨幣即時換算,以及各種匯率歷史變化圖。


  • 台灣空污警報(AirInfo)

    設定特定站點為推播通知關注點後,當該站點空氣品質變糟時,即時推播通知給您。另外提供站點附近基本天氣預測資料。


  • 國道一路通(FreeWay)

    打開定位即實際地圖上繪製所在地中心附近的車況圖,可縮放地圖,不再是小小的縮小圖,快速了解高速公路的路況。


  • 臉書粉絲專頁搜尋 (FPSearch)

    不用登入臉書即可搜尋臉書粉絲專頁(臉書粉絲團)所公開的文章。您可以指定特定日期範圍之前的文章,也可設定搜尋粉絲專頁內包含特定關鍵詞的文章。


  • 藝文快訊

    讓你可以輕鬆追蹤含有您想要關注關鍵詞的任何藝文活動訊息,只要有最新的資訊,「藝文快訊」即會推播通知給你.