public class PushMessageService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map<String,String> data = remoteMessage.getData();
String link = data.get("link");
String name = data.get("name");
if (link!=null) {
Log.d("link",link);
Log.d("name",name);
UpdateHelper.Go(this, link, name);
}
else {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_shop_white_24dp)
.setAutoCancel(true)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody());
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(5, mBuilder.build());
}
}
}
示例通知 在这里
为什么会这样?我该怎么做才能在应用程序关闭后运行我的代码?