
在iOS中,应用程序在后台使用“本地通知”时,通知用户发生了某些事情,他们可能需要注意:
Local notifications … to inform users when new data becomes available for your app, even when your app is not running in the foreground. For example, a messaging app might let the user kNow when a new message has arrived, and a calendar app might inform the user of an upcoming appointment.
Apple dev – Local and Remote Notifications Overview
[如果应用程序本身提供新数据,则为“本地”;如果远程服务器正在发送更新,则为“remote”.
在AndroID上有同等的地方吗?
解决方法:
如果您也定位旧API,请使用NotificationCompat.Builder.
Intent intent = new Intent(ctx, HomeActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(ctx); b.setautoCancel(true) .setDefaults(Notification.DEFAulT_ALL) .setWhen(System.currentTimeMillis()) .setSmallicon(R.drawable.ic_launcher) .setTicker("Hearty365") .setContentTitle("Default notification") .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") .setDefaults(Notification.DEFAulT_liGHTS| Notification.DEFAulT_SOUND) .setContentIntent(contentIntent) .setContentInfo("Info"); notificationmanager notificationmanager = (notificationmanager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); notificationmanager.notify(1, b.build()); 总结 以上是内存溢出为你收集整理的Android中的本地通知?全部内容,希望文章能够帮你解决Android中的本地通知?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)