这是我的清单
<service android:name=".fcm.PshycoFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".fcm.PshycoFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
当应用程序处于后台并且通知到达时,默认通知将会运行并且不会运行我的代码onMessageReceived.
这是我的onMessageReceived代码.如果我的应用程序在前台运行,而不是在后台应用程序时,则调用此方法.如何在应用程序处于后台时运行此代码?
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See …Run Code Online (Sandbox Code Playgroud) 我的问题如下:
我正在向通知栏发布通知,并且我已经在其中发送了一个URI链接.一旦我点击通知我得到一个对话框我想做什么,但它显示垃圾,如应用程序信息,条形码扫描仪,调用对话框.而不是浏览器.
我提出我的代码:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
PendingIntent contentIntent = PendingIntent.getActivity(contexta, 0, notificationIntent, 0);
notificationIntent.setData(Uri.parse("http://www.google.com"));
notification.setLatestEventInfo(contexta, contentTitle, contentText, contentIntent);
mNotificationManager.notify(970970, notification);
Run Code Online (Sandbox Code Playgroud)
所以我可能没想到正确的方向.我是否应该插入一个intent并在我自己的应用程序中有一个处理程序而是为浏览器创建一个新的意图?但那会很奇怪,为什么android无法正确处理我的初始意图呢.
一如既往,非常感谢任何和所有的帮助.
谢谢,罗汉.
我想向我的用户发送通知以记住他们更新应用程序,但我无法更改应用程序代码,因为问题显然是该应用程序已过时。
有没有办法通过 FCM 通知、使用clickAction或类似的方式打开 Play 商店,而无需对应用程序进行更改?
我的应用程序当前正在接收来自Firebase控制台的文本,图像和两者作为推送通知.我也希望将来自我的Firebase控制台的通知发送给应用用户.点击通知后,用户将被重定向到特定的网址,即www.facebook.com.如何在以下代码中执行此操作? 请看这个我想要的图像
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "FirebaseMessageService";
Bitmap bitmap;
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// There are two types of messages data messages and notification messages. Data messages are handled
// here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
// …Run Code Online (Sandbox Code Playgroud)