2017-05-16 50 views
2

我試圖通過iOS上的自定義分析系統跟蹤推送通知打開和解除,我一直無法獲得任何UNNotificationDismissActionIdentifier響應。customDismissAction不適用於遠程通知

我的代碼與通知中心註冊:

if([[[UIDevice currentDevice] systemVersion] integerValue] >= 10){ 
    UNNotificationCategory* generalCategory = [UNNotificationCategory 
               categoryWithIdentifier:@"GENERAL" 
               actions:@[] 
               intentIdentifiers:@[] 
               options:UNNotificationCategoryOptionCustomDismissAction]; 

    // Register the notification categories. 
    UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; 
    [center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]]; 
    [center setDelegate:self]; 
}; 

當我把我的推送通知,我的類別設置爲常規。當我收到通知並刷卡右鍵解除該通知時,我不會收到任何代表回撥。

customDismissAction只適用於本地通知嗎?

+0

您是否有幸運?不要'customDismissAction'假設你應該將一些動作傳遞給初始化器? – kelin

+0

你能告訴我們你的有效載荷結構嗎?是'aps'鍵下的'category'嗎? – Honey

回答

0

進入相同的問題。 documentation提到這需要成爲APS有效載荷的一部分以用於遠程通知。在我發現/接受之前,我不得不仔細閱讀它。確保在註冊解除操作時將所需的任何類別添加到推送有效內容並使其匹配。因此,如果您使用示例「GENERAL」,則有效載荷應包含該類別

"aps" : { 
    "category" : "GENERAL", 
    "alert" : { 
    "body" : "Some message", 
    }, 
    etc... 
}