使用firebase推送通知时出错

时间:2018-02-26 18:52:52

标签: firebase firebase-cloud-messaging

当我从前基地推送通知时,我遇到了这个错误

  

E / AudioFlinger:没有足够的内存用于AudioTrack size = 131296
      02-26 21:00:38.035 1328-1328 /? E / AudioFlinger:createRecordTrack_l()initCheck失败-12;没有控制块?
      02-26 21:00:38.035 2145-2256 /? E / AudioRecord:AudioFlinger无法创建记录轨道,状态:-12
      02-26 21:00:38.039 2145-2256 /? E / AudioRecord-JNI:创建AudioRecord实例时出错:初始化检查失败,状态为-12       02-26 21:00:38.039 2145-2256 /? E / android.media.AudioRecord:初始化本机AudioRecord对象时出现错误代码-20       02-26 21:00:38.040 2145-2256 /? E / ActivityThread:无法找到提供商信息   com.google.android.apps.gsa.testing.ui.audio.recorded

这是接收方法

 @Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    sendNotification(remoteMessage.getNotification().getBody());

}
private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("FCM Message")
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

0 个答案:

没有答案