从mixpanel收到消息时的声音通知

时间:2016-06-06 14:22:34

标签: android notifications push mixpanel

我已经在我的Android应用程序代码中集成了mixpanel,我正在收到推送通知,但我希望在消息到达时听到默认通知声音。 所以我添加了以下内容:

    public class notificationReceiver extends BroadcastReceiver {
    @Override
      public void onReceive(Context context, Intent MainActivity) {
         NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
Uri notification =  RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        mBuilder.setSound(notification);
Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(),    notification);
    r.play();  }
}

为什么这不会给mixpanel通知发声? 谢谢!

1 个答案:

答案 0 :(得分:0)

您必须在通知构建器

中添加此行代码
mBuilder.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);