本地通知 JPush 提供了本地推送的方法,可以灵活调用获取本地推送消息;注意 id 为 int 类型,设置不能过长; // 源码分析 const LocalNotification ({ @ fireDate = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch + 3000); var localNotification = LocalNotification( id: 000001, title: 'Local Push 本地标题', buildId: 1, content fireTime: fireDate, extra: {"extra_key": "extra_value"}); _jPush.sendLocalNotification(localNotification = LocalNotification( id: message2['id'], title: message2['title'], buildId:
count>0 else { return; } for localNotification in localNotifications! { guard let userInfo = localNotification.userInfo else{ continue; String) == "考勤"){ application.cancelLocalNotification(localNotification); }
与之对应两种通知分别是LocalNotification和RemoteNotification。 localNotice.alertAction = @"锁屏时的子标题"; localNotice.applicationIconBadgeNumber = 3; self.localNotification 0; } 其他常用API 取消(删除本地通知) // 删除某个本地通知 [[UIApplication sharedApplication] cancelLocalNotification:self.localNotification
NotifacationController代码中做一些操作: //在NotificationController中重写下面两个方法 //这个用于本地推送 override func didReceiveLocalNotification(localNotification , forLocalNotification localNotification: UILocalNotification) { } 专注技术,热爱生活,交流技术,也做朋友。
identifier:LOC_IDENTIFIER]; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification
尤其是 IOS 客户端本地,采用系统级别 localnotification 触发提醒,无法阻止。这最后必然导致用户投诉,业务方口碑受损。
launchOptions { [UNUserNotificationCenter currentNotificationCenter].delegate = self; // NSDictionary *localNotification