想问一下,现在我们的android app已经集成了chatkit,但是没有消息提醒(铃声或是震动),但是安装你们的demo就能听到铃声,想问一下是什么原因呢
-
创建时间
18年8月13日
-
最后回复
18年8月14日
- 5
回复
- 607
浏览
- 3
用户
- 2
链接
想问一下,现在我们的android app已经集成了chatkit,但是没有消息提醒(铃声或是震动),但是安装你们的demo就能听到铃声,想问一下是什么原因呢
Android 应用在后台的通知分为两种:
1、没有被杀掉,在 onMessage 事件中自行弹出通知窗口。ChatKit 的实现方式在:
2、被杀掉了,通过混合推送推送通知:
https://leancloud.cn/docs/android_push_guide.html#hash860147210
Android 应用是在后台的通知是通过onMessage的,而且也走了这个方法但是就是没有消息提醒
public static void showNotification(Context context, String title, String content, String sound, Intent intent) {
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(context.getApplicationInfo().icon)
.setContentTitle(title).setAutoCancel(true).setContentIntent(contentIntent)
.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)
.setContentText(content);
NotificationManager manager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = mBuilder.build();
if (sound != null && sound.trim().length() > 0) {
notification.sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + sound);
}
lastNotificationId = (lastNotificationId > 10000 ? 0 : lastNotificationId + 1);
manager.notify(lastNotificationId, notification);
}