小编Tam*_*abu的帖子

单击推送通知时进行特定活动的意图。

当应用程序在后台/未运行时,未在通知点击上打开特定活动

仅当打开应用程序并执行通知单击时,通知单击才会启动指定的活动。如果应用程序在后台运行/未运行,并且执行了单击通知,则将打开应用程序的MainActivity。简而言之,就像应用程序通常在活动堆栈之后打开,而不是在PendingIntent中打开指定的活动。

Firebase实例ID服务:

package com.example.tamzid.pushnotification;

 import android.util.Log;
 import com.google.firebase.iid.FirebaseInstanceId;
 import com.google.firebase.iid.FirebaseInstanceIdService;

 public class MyAndroidFirebaseInstanceIdService extends 
FirebaseInstanceIdService {

private static final String TAG = "MyAndroidFCMIIDService";

@Override
public void onTokenRefresh() {
    //Get hold of the registration token
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    //Log the token
    Log.d(TAG, "Refreshed token: " + refreshedToken);
}
private void sendRegistrationToServer(String token) {
    //Implement this method if you want to store the token on your server
}
}
Run Code Online (Sandbox Code Playgroud)

Firebase消息服务:

 package com.example.tamzid.pushnotification;

 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent; …
Run Code Online (Sandbox Code Playgroud)

android push-notification android-intent android-notifications intentservice

5
推荐指数
1
解决办法
1811
查看次数