firebasemessaging.sbackgroundmessage当我的应用在扑面而来时不会调用,仅在iOS设备中发生。

发布于 2025-02-13 05:49:03 字数 91 浏览 0 评论 0 原文

我正在制作一个具有推送通知属性应用程序的应用程序,当我们在前景上点击通知时,但是当应用在后台我的_backgroundHandler()方法时,它仅在iOS应用中才发生

I Am making an app which has push notification Property app is working when we hit notification on the foreground , but when app is on background my _backgroundHandler() method is not invoking, its happening only In IOS App Only

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

还不是爱你 2025-02-20 05:49:03

还挣扎了这个问题。

设置有效载荷如下。 可变的容器很有意义。

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}

https://github.com/github.com/fire.com/firebase/firebase/flutterfire/flutterfire/sissues/sissues/9381#issuececomment-122222296667020.66666666666670

设置iOS在有效载荷中的“可变容器:1”将通知传递给我们的通知服务应用程序扩展。

有关更多信息APNS有效载荷,请参见以下链接:

https://developer.apple.com/documentation/usernotification/setting_up_a_a_remote_notification_server/generating_a_remote_notification_notification_notification

also struggle this issue.

set payload as below. mutable-content make sense.

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}

https://github.com/firebase/flutterfire/issues/9381#issuecomment-1229167020

set "mutable-content:1" in payloads, iOS passes the notification to our notification service app extension.

For more information APNs payload, see the following links:

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification

撩人痒 2025-02-20 05:49:03

在XCode中启用背景获取,背景处理和远程通知

编辑

添加可变的键

{
“ to”:“ dwdhfjfjdbzbmjj5 ....”,
“ content_available”:是的,
“ mutable_content”:true,

“ data”:
{
“消息”:“一些味精”,
“ MediaUrl”:“在这里图像URL”
},

“通知”:
{
“身体”:“通知味觉”,
“声音”:“默认”
}
}

编辑


var payload = {
    notification: {
      title: `msg title here`,
      body: `msg body here`
      }`,
    },
    // Set Android priority to "high"
    android: {
      priority: "high",
    },
    // Add APNS (Apple) config
    apns: {
      payload: {
        aps: {
          contentAvailable: true,
        },
      },
      headers: {
        //"apns-push-type": "background", // This line prevents background notification
        "apns-priority": "10",
      },
    },
    token: "dnqTQVso60GfnnuOjHv8_e:APA91bElr-K3xkQMdYHX8VMrasdfasdfkjhasidfgjn"
 };

Enable background fetch, background processing and remote notification in Xcode
preview

Edit

Add mutable key to payload

{
"to": "dWdhfjfjdbzbmjJ5....",
"content_available": true,
"mutable_content": true,

"data":
{
"message": "some msg",
"mediaUrl": "image url here"
},

"notification":
{
"body": "notification msg",
"sound": "default"
}
}

EDIT


var payload = {
    notification: {
      title: `msg title here`,
      body: `msg body here`
      }`,
    },
    // Set Android priority to "high"
    android: {
      priority: "high",
    },
    // Add APNS (Apple) config
    apns: {
      payload: {
        aps: {
          contentAvailable: true,
        },
      },
      headers: {
        //"apns-push-type": "background", // This line prevents background notification
        "apns-priority": "10",
      },
    },
    token: "dnqTQVso60GfnnuOjHv8_e:APA91bElr-K3xkQMdYHX8VMrasdfasdfkjhasidfgjn"
 };
初相遇 2025-02-20 05:49:03

在我的有效载荷中添加此问题解决了我的问题:

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}

Adding this in my payload solved my issue:

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}

旧人 2025-02-20 05:49:03

我也面临这个问题。

@Goza的答案应该被接受。

这是我的发送JSON。

{
   "message":{
      "token":"fcm token",
      "notification":{
         "title":"NotifyTitle",
         "body":"NotifyBody"
      },
      "data":{
         "title":"DataTitle",
         "body":"DataBody"
      },
      "apns":{
          "payload":{
             "aps":{
                "content-available":1
             }
          }
       }
   }
}

I have face this issue too.

@goza's answer should been accepted.

This is my sending json.

{
   "message":{
      "token":"fcm token",
      "notification":{
         "title":"NotifyTitle",
         "body":"NotifyBody"
      },
      "data":{
         "title":"DataTitle",
         "body":"DataBody"
      },
      "apns":{
          "payload":{
             "aps":{
                "content-available":1
             }
          }
       }
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文