2017-09-22 98 views
0

我已經爲本地通知實施了交互式提醒。但是這些交互選項只有在設備被解鎖並且用戶在接收後立即拉下提醒時纔可見。第一張圖片剛剛收到本地通知後顯示。iOS中不顯示交互式提醒選項

Just after receiving

如果你刷卡向左或向右沒有發生。但是,如果你拉下來,那麼你可以看到兩個交互選項。就像在第二個圖像。

enter image description here

(Q1)其實,我的第一個問題是,爲什麼它只是顯示只有兩種選擇,而我已經聲明瞭三個互動選擇?

下面是我的相關代碼。

UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init]; 
notificationCategory.identifier = mutableUserNotificationCategoryId; 
[notificationCategory setActions:@[notificationAction1, notificationAction2, notificationAction3] forContext:UIUserNotificationActionContextDefault]; 
[notificationCategory setActions:@[notificationAction1, notificationAction2, notificationAction3] forContext:UIUserNotificationActionContextMinimal]; 

NSSet *categories = [NSSet setWithObjects:notificationCategory, nil]; 

UIUserNotificationType types = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert); 
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; 
[application registerUserNotificationSettings:settings]; 

(Q2)我的第二個問題是,爲什麼我們不能看到交互式選項時,用戶在刷卡任何其他階段的通知。 (例如通知中心下的通知顯示)請查看我上傳的下一張圖片。

enter image description hereenter image description here

+0

如果其支持3D觸摸的設備,通知操作在3D觸摸上可用。 –

回答

0

如果使用UIUserNotificationActionContextMinimal然後通知警告將顯示此背景下不超過2自定義操作。 Docs

在啓用3D觸摸的設備上,下拉警報或使用三維觸摸手勢時可以使用通知警報操作。您想查看自定義操作的方式適用於非3d觸摸設備。

+0

我已經刪除了'UIUserNotificationActionContextMinimal'行,但保留了默認上下文的三個選項。但即使如此,它只是向我展示了最後兩種選擇。 – AnujAroshA

+0

此外,我只用一個通知在OS版本10.3.2的iPhone 6S上進行測試。所以,我認爲它應該有足夠的空間來顯示所有三個選項。 – AnujAroshA