如何在expo react native app中设置Android / IOS推送通知的自定义图标?

e0bqpujr  于 5个月前  发布在  Android
关注(0)|答案(1)|浏览(60)

请检查问题问here的更多信息,因为我想实现正是在世博会React Native
我试过使用通知包和Notifee包,但似乎找不到添加此功能的方法
push notification with custom icons

93ze6v8z

93ze6v8z1#

这可以通过Notifee/react-native包来实现,它适用于bare expo和react native expo项目,对于bare expo项目,在安装notifee后,按照他们的文档here,然后通过app.json文件将所需的功能添加到应用程序中,

"ios": {
       "entitlements": {
          "com.apple.developer.usernotifications.communication": true
       },
      "infoPlist": {
          "UIBackgroundModes": ["location", "fetch", "remote-notification"],
      "NSUserActivityTypes": ["INSendMessageIntent"]
    },
   }

字符串
这为ios添加了通信通知功能,还将INSendMessageIntent添加到info.plist中的NSUserActivityTypes
然后使用Notifee包显示通知,方法是:

await notifee.displayNotification({
  title: "Some title",
  body: "Notification Body",
  ios: {
    foregroundPresentationOptions: {
      badge: true,
      sound: true,
      banner: true,
      list: true,
    },
    categoryId: 'messageID',
    communicationInfo: {
      conversationId: "123",
      sender: {
        id: "456",
        avatar: "Avatar-url",
        displayName: "John Doe",
      },
    },
  }
})

相关问题