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 推播服務的改變”

站內搜尋



本站其他服務

本站其他軟體



  • 油價快訊App (OilPrices)

    依據油價及匯率,估算台灣下週油價,另外提供三週、一年以及三年的歷史變化,以及週末下午推播通知最新油價預估或公告。


  • 標案快訊

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


  • 股海快訊 (iNews123)

    提供特定個股新聞更新推播、股價警示推播、新聞社群分享以及每日個股收盤價等功能的股票App/股市App.


  • 藝文快訊

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


  • 姓名筆畫吉凶查詢系統

    這是一個提供中文字康熙筆畫的小軟體,並根據農民曆計算每個名字或公司名的總筆畫以及最後的吉凶數,共有四種模式


  • 當令蔬果花卉(AgriInfo)

    是不是常常在超市看到水果蔬菜的價格,總是不確定是當季蔬果?這個服務就是幫你很快判斷眼前的蔬果花卉的價格是否便宜。