如何立即在iOS 10和11运行设备中显示本地通知,我的应用程序要求是立即向用户显示本地通知,因为我们需要首先请求本地通知,然后系统安排通知。我正在运行此代码用于显示本地通知。
UNMutableNotificationContent *content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
content.sound = [UNNotificationSound defaultSound];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
/// 3. schedule localNotification
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (!error) {
NSLog(@"Local Notification succeeded");
}
else {
NSLog(@"Local Notification failed");
}
}];
答案 0 :(得分:0)
您可以尝试....
<a id="a" href=""> A</a>
<br /><br />
<a id="b" href=""> B</a>
<br /><br />
<a id="c" href=""> C</a>
<div id="bg"></div>