当我收到在后台启动我的应用程序的远程推送通知(VoIP PushKit)时,我正在尝试触发本地通知。
我在 UNUserNotificationCenter 的待处理通知数组中看到了我的本地通知。
[[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:
^(NSArray<UNNotificationRequest *> * _Nonnull requests)
{
NSLog(@"Local notifications: %@",requests);
}];
"<UNNotificationRequest: 0x17162e500; identifier: 2A364020-3BA2-481B-9255-16EBBF2F4484, content: <UNNotificationContent: 0x1708e8080; title:test, subtitle: (null), body: test2, categoryIdentifier: missed, launchImageName: , peopleIdentifiers: (\n), threadIdentifier: , attachments: (\n), badge: 1, sound: <UNNotificationSound: 0x1704bfe60>, hasDefaultAction: YES, shouldAddToNotificationsList: YES, shouldAlwaysAlertWhileAppIsForeground: YES, shouldLockDevice: YES, shouldPauseMedia: NO, isSnoozeable: NO, fromSnooze: NO, darwinNotificationName: (null), darwinSnoozedNotificationName: (null), trigger: <UNTimeIntervalNotificationTrigger: 0x171624260; repeats: NO, timeInterval: 5.000000>>"
但它在 5 秒后没有出现。我使用 UNTimeIntervalNotificationTrigger。
当应用程序在前台时,我已成功调用本地通知。我通过按下按钮调用它来使用相同的触发功能。
当iOS应用程序在后台时,有什么方法可以触发本地通知?