三星S8/S5/J2/Note3正在Firebase Push Notification成功应用程序被杀死,在后台或前台,
但Infinix Note 5 (Android One- Oreo)和Oppo F9(Oreo)如果应用程序被杀害没有得到推送通知,他们的工作很好,如果应用程序在背景或前景.
我经历了很多文章,这个和这个,提到中国手机有这个问题,并且用户方面有一些工作来使这些通知在他们的手机上工作.
但我想知道从开发方面是否有可能在每个Android设备上进行通知工作.
我的目标是API 27,这是我的代码
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
String from = remoteMessage.getFrom();
Map data = remoteMessage.getData();
JSONObject jsonObject = new JSONObject();
Set<String> keys = remoteMessage.getData().keySet();
for (String key : keys) {
try {
jsonObject.put(key, remoteMessage.getData().get(key));
} catch (JSONException e) {
e.printStackTrace();
}
}
message= jsonObject.getString("message");
sendNotification(message, urlToOpen);
private void …Run Code Online (Sandbox Code Playgroud) performance android firebase firebase-cloud-messaging android-push-notification
我已经在我的应用程序中实现了 Firebase,我正在发送带有额外数据的推送。当我的应用程序处于前台时,我正在正确处理数据并显示我自己的通知,但我在获取数据时遇到问题,当应用程序“归位”(未终止)时 Firebase 会“自动”显示通知。根据DOCS Activity应该得到新Intent的附加值满足我的价值观,而不是应用程序回到前面,恢复旧状态。
设想:
Notification无需调用onMessageReceived(根据文档中的表格,它应该?)Intent使用用于打开Activity顶部的“原始”附加功能来实现我有登录onCreate, onNewIntent, onResume( Activity) 和onMessageReceived( Service), onlyonResume被调用,其中我正在打印如下附加内容:
if (getIntent().getExtras() != null) {
for (String key : getIntent().getExtras().keySet()) {
Object value = getIntent().getExtras().get(key);
Log.d("Activity onResume", "Key: " + key + " Value: " + value);
}
}
Run Code Online (Sandbox Code Playgroud) android push-notification firebase firebase-cloud-messaging android-push-notification
我想要的是:我想向用户发送推送通知。当用户点击该通知时,用户应导航到特定活动。
我做了什么:我在Firebase控制台中创建了一个深层链接。我也实现了FirebaseInstanceIdService和FirebaseMessagingService。我能够捕获从Firebase控制台发送的Firebase消息。
问题是什么:我无法捕获在Firebase控制台中创建的动态链接。
我的代码如下。
MyFirebaseInstanceIDService.java
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private final String TAG = "MyFirebaseInstanceID";
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.e(TAG, "Refreshed token: " + refreshedToken);
}
}
Run Code Online (Sandbox Code Playgroud)
MyFirebaseMessagingService.java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private final String TAG = "MyFbaseMessagingService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String message = remoteMessage.getNotification().getBody();
Log.e(TAG, "\nmessage: " + message);
sendNotification(message);
}
private void sendNotification(String message) {
Intent intent = new …Run Code Online (Sandbox Code Playgroud) deep-linking firebase firebase-cloud-messaging firebase-dynamic-links android-push-notification
如何在小米设备上以编程方式启用抬头通知?某些应用程序(例如 Telegram)默认启用此权限。
设置截图:https : //imgur.com/a/D48G8Mz
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel( ) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
channel.enableLights(true);
channel.setLightColor(Color.RED);
channel.enableVibration(true);
channel.setSound(createNotificationSound(),
new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build());
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
return CHANNEL_ID;
}
Run Code Online (Sandbox Code Playgroud)
通知
String channelId = "";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
channelId = createNotificationChannel();
}
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, channelId)
.setLargeIcon(icon)
.setSmallIcon(R.mipmap.ic_mipmap_launcher)
.setContentTitle("Title")
.setTicker(getResources().getString(R.string.app_name))
.setContentText("Text")
.setSound(createNotificationSound(), AudioManager.STREAM_NOTIFICATION)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setChannelId(channelId)
.setPriority(Notification.PRIORITY_HIGH);
NotificationCompat.InboxStyle inboxStyle =
new NotificationCompat.InboxStyle();
notificationBuilder.setStyle(inboxStyle);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); …Run Code Online (Sandbox Code Playgroud) android push-notification heads-up-notifications android-push-notification xiaomi
在 Android 中,如果我们使用操作系统设置禁用应用程序通知,fcm/gcm 是否仍会将通知发送到设备?
如果发送到设备,通知是否会传递到应用程序?还是操作系统阻止了它?
我假设当我们禁用通知时,Android 操作系统会将这些设置传达给 fcm/gcm 服务器。
android push-notification firebase google-cloud-messaging android-push-notification
是否可以像在 iOS 中那样将视频嵌入到 android 丰富的通知中?我知道 android 官方仍然不支持,但它可能是一些即兴创作的棘手方法?:)
提前致谢。
java android push-notification android-remoteview android-push-notification
我的问题是:我可以在局域网环境中实现 android 推送通知吗?
有什么技巧可以做到吗?
谢谢!
我正在使用“flutter_app_badger”作为应用程序图标徽章。它在三星上运行良好,但在 Redmi、vivo 等某些设备上无法正常工作。我该如何处理?我们是否可以选择通过 iOS 等通知负载添加“徽章”?
Android 7.0 Nougat添加了Data Saver功能,允许用户限制某些应用的背景数据(包括推送通知).当Data Saver为ON时,仅列出列表中的应用程序
设置→数据保护→无限制数据访问
允许接收推送通知并执行后台网络呼叫.如果Data Saver处于关闭状态且您的应用程序不在非限制列表中,则非常类似于禁用设置推送通知.
我的应用程序中有一个用例,它正在等待推送通知.
我想知道是否有办法找出数据保护程序是否已启用,如果我的应用程序位于"无限制数据访问"列表中,可能知道是否为我的应用程序启用了推送通知,因此是否有一点等待当应用程序在特定时间处于后台时,推送并有机会执行任何网络呼叫.
我已经在Huawei AppGallery上发布了一个Android应用程序,并且能够通过HMS Push Service从我的应用程序后端服务器向手机发送推送通知(非透明),如下所述。
但是,我想知道如何在应用程序中访问推送通知有效内容:
这是我目前发送推送通知的方式-
首先,我到https://login.vmall.com/oauth2/的后端POST标记以下内容:
grant_type=client_credentials&client_id=101130655&client_secret=XXXXX
Run Code Online (Sandbox Code Playgroud)
并成功从HMS后端获取访问令牌:
{
"access_token":"CF1/tI97Ncjts68jeXaUmxjmu8BARYGCzd2UjckO5SphMcFN/EESRlfPqhi37EL7hI2YQgPibPpE7xeCI5ej/A==",
"expires_in":604800
}
Run Code Online (Sandbox Code Playgroud)
然后,我的后端POST到(对进行URL编码{"ver":"1", "appId":"101130655"})-
https://api.push.hicloud.com/pushsend.do?nsp_ctx=
%7B%22ver%22%3A%221%22%2C+%22appId%22%3A%22101130655%22%7D
Run Code Online (Sandbox Code Playgroud)
以下URL编码的正文:
access_token=CF1/tI97Ncjts68jeXaUmxjmu8BARYGCzd2UjckO5SphMcFN/EESRlfPqhi37EL7hI2YQgPibPpE7xeCI5ej/A==
&nsp_svc=openpush.message.api.send
&nsp_ts=1568056994
&device_token_list=%5B%220869268048295821300004507000DE01%22%5D
&payload=%7B%22hps%22%3A%7B%22msg%22%3A%7B%22action%22%3A%7B%22param%22%3A%7B%22appPkgName%22%3A%22de%2Eslova%2Ehuawei%22%7D%2C%22type%22%3A3%7D%2C%22type%22%3A3%2C%22body%22%3A%7B%22title%22%3A%22Alexander%3A+How+to+access+payload%3F%22%2C%22content%22%3A%22Alexander%3A+How+to+access+payload%3F%22%7D%7D%2C%22ext%22%3A%7B%22gid%22%3A86932%7D%7D%7D
Run Code Online (Sandbox Code Playgroud)
payload值在哪里(我不确定,它是否具有正确的JSON结构以及“类型” 3的真正含义):
{
"hps": {
"msg": {
"action": {
"param": {
"appPkgName": "de.slova.huawei"
},
"type": 3
},
"type": 3,
"body": {
"title": "Alexander:+How+to+access+payload?",
"content": "Alexander:+How+to+access+payload?"
}
},
"ext": {
"gid": 86932
}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要提取自定义整数“ gid”值(我的应用中的“游戏ID”)。
在自定义接收器类中,我定义了以下方法,但未调用它们(该onToken方法除外-当我的应用启动并通过调用HuaweiPush.HuaweiPushApi.getToken方法异步从HMS请求“推送令牌”时):
public class MyReceiver …Run Code Online (Sandbox Code Playgroud) android push-notification huawei android-push-notification huawei-mobile-services
android ×8
firebase ×4
dart ×1
deep-linking ×1
flutter ×1
huawei ×1
java ×1
performance ×1
xiaomi ×1