相关疑难解决方法(0)

iOS 7中的静默推送通知不起作用

在WWDC 2013的"多任务新功能"演示中,有一个关于静音推送通知的部分.看起来很简单.根据演示文稿,如果您将APS有效负载仅发送到内容可用设置为1,则不会通知用户该通知.

// A. This doesn't work
{ 
  aps: { 
          content-available: 1 
       }
}
Run Code Online (Sandbox Code Playgroud)

我的测试显示,这不起作用,因为没有收到推送.但是,如果我包含声音属性但排除了alert属性,它就会起作用(虽然不再是静音).

// B. This works
{ 
  aps: {
          content-available: 1,
          sound: "default"
       }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我更改声音属性以播放静音,我可以模仿静音.

// C. This works too.
{ 
  aps: {
          content-available: 1,
          sound: "silence.wav"
       }
}
Run Code Online (Sandbox Code Playgroud)

有人知道吗:

  1. 如果这是一个bug?
  2. 如果假设B或C被视为远程通知是正确的(而不是Silent Push需要声音属性的错误)?如果是这样,这意味着它没有像Silent Pushes那样的速率限制...... Apple可能会解决这个问题.所以我可能不应该依赖它.
  3. 速率限制是什么(N每推X秒等)?

提前致谢.

编辑更多信息

对于A,应用程序的状态无关紧要.从未收到通知.

看起来B和C只有在将属性和值括在引号中时才有效,如下所示.

{"aps":{"content-available": 1, "sound":"silent.wav"}}
Run Code Online (Sandbox Code Playgroud)

并且通知到达应用程序:didReceiveRemoteNotification:fetchCompletionHandler:无论状态如何.

push-notification ios ios7

86
推荐指数
4
解决办法
6万
查看次数

curl发送的Firebase云消息传递警报在iOS设备上无法显示

我正在尝试将从我的服务器发送到FCM的Firebase Cloud Messaging iOS警报显示在我的iOS设备上.

如果我从FCM控制台发送消息:

https://console.firebase.google.com/project/ your-awesome-project/notification

和FCM示例应用程序:

https://github.com/firebase/quickstart-ios

关闭或在后台,警报显示美妙,

如果它在前台我在iOS控制台中看到这个:

{
    aps =     {
        alert = "HEY YO";
    };
    "gcm.message_id" = "0:123456789_blah_blah";
    "gcm.n.e" = 1;
    "google.c.a.c_id" = 123XXXXXXXX789;
    "google.c.a.e" = 1;
    "google.c.a.ts" = 123XXX789;
    "google.c.a.udt" = 0;
}
Run Code Online (Sandbox Code Playgroud)

......但如果我试试这个:

curl -X POST 
--header "Authorization: key=<server key>" 
--header "Content-Type: application/json" 
https://fcm.googleapis.com/fcm/send
-d "{\"to\":\"<device registration id>\",\"notification\":{\"body\": \"HEY YO\"}}"
Run Code Online (Sandbox Code Playgroud)

...无论FCM示例应用程序是在前台,后台还是完全关闭,它都不会显示为警报.

然而它确实出现在iOS控制台中,但参数较少:

{
    aps =     {
        alert = "HEY YO";
    };
    "gcm.message_id" = "0:123456789_blah_blah";
}
Run Code Online (Sandbox Code Playgroud)

是否可以使用curl触发在我的iOS设备上显示为警报的Firebase云消息通知?

答案 [感谢亚瑟!] :

只需添加: \"priority\":\"high\"

像这样: …

curl apple-push-notifications ios google-cloud-messaging firebase-cloud-messaging

10
推荐指数
1
解决办法
4668
查看次数

当应用程序处于后台/终止状态并且收到 FCM 通知时,如何在 Flutter 中显示本地通知?

我正在尝试在我的 Flutter 应用程序中使用 Firebase Cloud Messaging 实现推送通知服务。这就是 FCM 文档所说的我们应该根据应用程序的当前状态(前台、后台或终止)处理通知的方式:

Foreground:我们有一个onMessage可以监听的流,但 FCM在前台状态时不会显示任何通知,因此我们必须使用FlutterLocalNotificationsPlugin它,这是我的实现:

FirebaseMessaging.onMessage.listen((RemoteMessage remoteMessage) {
      // calling flutter local notifications plugin for showing local notification
      scheduleNotification(remoteMessage);
    });
Run Code Online (Sandbox Code Playgroud)

scheduleNotification方法中我调用该FlutterLocalNotificationsPlugin().show()方法,到目前为止一切都按预期工作

问题从这里开始:

后台,终止:Firebase 在此状态下自动显示通知,并且它有一个onBackgroundMessage。方法,我们可以向该方法传递一个在FCM 显示通知运行的BackgroundMessageHandler 。这是我的后台处理程序的实现:

Future<void> backgroundMessageHandler(
    RemoteMessage remoteMessage) async {
  RemoteNotification? remoteNotification = remoteMessage.notification;
  if (remoteNotification != null) {
    FlutterLocalNotificationsPlugin().show(
        remoteMessage.messageId.hashCode,
        remoteNotification.title,
        remoteNotification.body,
        NotificationDetails(
          android: AndroidNotificationDetails(
              _androidNotificationChannel.id,
              _androidNotificationChannel.name,
              _androidNotificationChannel.description,
              icon: 'launch_background',
              importance: …
Run Code Online (Sandbox Code Playgroud)

mobile push-notification firebase flutter firebase-cloud-messaging

6
推荐指数
1
解决办法
7648
查看次数

在iOS上按“标签”进行FCM ​​/ GCM分组通知

因此,在向Android设备发送通知时,您可以指定标签属性:

"notification": {
    "title": title,
    "body": message,
    "sound": sound,
    "tag": "STRING_TO_GROUP_NOTIFICATIONS_BY"
}
Run Code Online (Sandbox Code Playgroud)

这会将具有相同标签的通知分组在一起,以便在有大量通知时不会给用户带来混乱,而只会显示最新的通知。

这对于说说聊天应用程序非常有用,它具有多个接收大量消息的频道,因此您可以按频道分组并最大程度地减少用户通知中的噪音。

安薇

iOS有什么方法可以做到这一点吗?

android ios firebase google-cloud-messaging firebase-cloud-messaging

3
推荐指数
1
解决办法
3625
查看次数

设备上收到 Android FCM 通知。但显示器打不开

我正在开发一个带有 FCM 通知的 Android 应用程序。当应用程序在后台或前台时,我都能正确收到通知;它会发出声音并振动,单击通知会启动应用程序。一切都恰到好处。但是,当设备锁定且显示屏关闭时,设备会在收到通知时振动并发出声音。但它没有唤醒(屏幕没有打开)。只有在按下按键后,设备才会唤醒,即使在锁定屏幕中我也可以看到通知。

我有两个问题,

  1. 如何打开显示器?

  2. 如何在锁定时间屏幕中显示应用程序图标,就像锁定屏幕中的whatsapp徽标一样?

谢谢,维鲁

notifications android display

2
推荐指数
1
解决办法
3575
查看次数