我在下面的代码中使用FCM进行推送通知,以便在收到通知时播放声音
public void playNotificationSound() {
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(mContext, notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我正在调用这个OnMessageReceived方法,但声音仅在应用处于前景时播放,而不是在应用处于后台时播放
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage == null)
return;
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
handleNotification(remoteMessage.getNotification().getBody());
}
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Data Payload: " …
Run Code Online (Sandbox Code Playgroud) android push-notification android-notifications firebase firebase-notifications
我最近更新了我的firebase消息传递盒,并按照Firebase的快速入门指南执行必要的升级更改.
我添加了新的extension AppDelegate : MessagingDelegate
扩展程序,但遇到了一些错误.
我遇到了问题,因为我正在测试我的应用程序的某些设备没有收到通知,也没有引发异常.
通知来自FCM,我正在使用自定义服务来显示它们.
MyFirebaseMessaginService.java
static int count = 0;
@Override
public void onMessageReceived(final RemoteMessage remoteMessage) {
Log.i("remoteMessage",remoteMessage.toString());
switch(remoteMessage.getData().get("tipo")){
case "normal":
notificacionNormal(remoteMessage);
break;
case "imagen":
notificacionImagen(remoteMessage);
break;
case "imagen+url":
notificacionImagenUrl(remoteMessage);
break;
}
count++;
//Log.d("prueba",remoteMessage.getData().get("imagen"));
}
private void notificacionImagenUrl(RemoteMessage remoteMessage) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(remoteMessage.getData().get("url")));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 100, i, PendingIntent.FLAG_ONE_SHOT);
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification.Builder(this)
.setContentIntent(pendingIntent)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setStyle(new Notification.BigPictureStyle().bigPicture(getImagae(remoteMessage.getData().get("imagen"))))
.build();
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(count, notif);
}
Run Code Online (Sandbox Code Playgroud)
目前它只发生在一个带有android 6.0.1的root设备中希望你可以帮助我:)
编辑:我发送的通知HTTP请求:
"to": …
Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-notifications
我目前正在开发一个应用程序,我已经在我的应用程序中实现了firebase推送通知服务.我收到了我的iphone上的通知,但我无法设置我想要的自定义警报声.
Copy Bundle Resources
使用print (userInfo)
我收集了来自Firebase的数据
aps: {
alert = {
body = MSG;
title = Title;
};
sound = default;}, {...}, sound: alarm.caf
Run Code Online (Sandbox Code Playgroud)
我明白问题所在,我只是不明白如何解决它,以便应用程序播放我的自定义通知声音.
在一个应用程序中对Firebase云消息传递的不同主题数量有任何限制吗?
我正在使用FCM进行简单通知
当应用程序处于前台时,一切正常.我收到通知以及onMessageReceived
方法内的数据消息.
但是当应用程序处于后台时,我会在系统托盘中收到通知.当我点击控件时,它会转到主要活动.当我分析intent.getExtras();
,我只得到这个关键的数据- ,google.sent_time
,from
,.google.message_id
collapse_key
如何获取系统托盘中可见的通知消息标题和消息intent.getExtras()
?
我正在使用FCM控制台发送通知我没有我的专用服务器来执行此操作.
接收邮件的代码:
final Bundle extras = intent.getExtras();
final Set<String> keySet = extras.keySet();
final Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
final String key = iterator.next();
final Object o = extras.get(key);
System.out.println(key + ":" + o);
}
Run Code Online (Sandbox Code Playgroud) android firebase firebase-cloud-messaging firebase-notifications
我在firebase控制台中有一个项目,这个项目有两个android都是应用程序.我只整合了Analytics,Notifications和Crashlytics.我曾想过只是删除应用程序并重新添加到我为其创建的firebase中的新项目,但我不知道安装了应用程序的当前用户会发生什么.无论如何,除了删除它并将其重新添加到新项目之外,我可以将此应用程序迁移到新项目.我试图谷歌并寻找解决方案,但所有解决方案都指示我将应用程序迁移到另一个帐户而不是同一帐户中的另一个项目.如果您有任何想法或建议,请帮助我.谢谢.
android firebase firebase-notifications firebase-crash-reporting
我正在尝试为 Flutter 应用程序实现通知。
在 iPhone(左)上,它看起来像预期的一样,通知会显示很短的时间,然后自动隐藏。
但是在 Android(右侧,Android 9,motorola)上,它在状态栏中显示为一个图标。
我怎样才能让它弹出?现在我必须向下滑动它才能看到内容。
通知是通过 Firebase 和他们的PHP-Sdk 发送的。
$serviceAccount = ServiceAccount::fromJsonFile('....');
$firebase = (new Factory)
->withServiceAccount($serviceAccount);
$messaging = $firebase->createMessaging();
$title = 'Test Titel '.date('YmdHis');
$body = 'Meine Nachricht '.date('YmdHis');
$colkey = 'newmessagtenoti';
$count = 23;
$message = new RawMessageFromArray([
'notification' => [
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification
'title' => $title,
'body' => $body,
],
'data' => [
'key_1' => 'Value 1',
'key_2' => 'Value 2',
],
'android' => [
// https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidconfig
'ttl' => '3600s',
'priority' => …
Run Code Online (Sandbox Code Playgroud) android flutter firebase-cloud-messaging firebase-notifications
我想将带有 FCM 的 url 发送到 android 应用程序。单击 FCM 通知而不是打开启动器活动时,是否可以打开浏览器?我知道可以使用覆盖onMessageReceived()
方法,但我不想这样做。我检查了click_action
有效负载中的参数,但正如 Firebase 所说:
如果指定,则当用户单击通知时将启动具有匹配意图过滤器的活动。
我尝试click_action
在 firebase cloudMessaging 面板中添加CustomData ,如下所示:
但它不起作用并打开应用程序。
我使用邮递员为此目的发送通知并添加click_action
到这样的notification
对象:
通知发送到我的设备,但当点击它时,什么也没发生!!!
重要提示:我的 apk 在 GooglePlay 上发布,我无法更改应用程序的源代码。
请任何人帮忙。
android firebase firebase-cloud-messaging firebase-notifications