简体   繁体   English

Detached Expo (ExpoKit) 推送通知

[英]Detached Expo (ExpoKit) Push Notifications

I've just detached my expo project to ExpoKit and I'm trying to figure out how to handle push notifications.我刚刚将我的博览会项目与 ExpoKit 分离,我正在尝试弄清楚如何处理推送通知。 On Android, I have FCM, which worked out of the box right after I did the expo eject, the AndroidManifest.xml was correctly populated and the FCM_ENABLED in AppContastants.java was set to TRUE.在 Android 上,我有 FCM,它在我完成博览会弹出后立即运行,正确填充了 AndroidManifest.xml 并且 AppContastants.java 中的 FCM_ENABLED 设置为 TRUE。

On the other hand, on iOS, I find it a bit more complicated, I'm not even sure if I'm on the right track because there are so many different approaches all over the internet.另一方面,在 iOS 上,我发现它有点复杂,我什至不确定我是否在正确的轨道上,因为互联网上有很多不同的方法。 From what I understood, one can still use the Notifications from React, but he needs to provide the certificates.据我了解,仍然可以使用 React 的通知,但他需要提供证书。 Can someone confirm this?有人可以证实这一点吗? Because I've generated my own certificates, enabled everything related in XCode and it still does not work.因为我已经生成了自己的证书,启用了 XCode 中的所有相关内容,但它仍然不起作用。

I've also tried adding PushNotificationsIOS, added all the methods in the AppDelegate.m, the code builds, but I don't get any push notifications on iOS.我也尝试添加 PushNotificationsIOS,添加 AppDelegate.m 中的所有方法,代码构建,但我在 iOS 上没有收到任何推送通知。 I'm not even sure if I need to write some code in the react-native app, not only in the native code.我什至不确定是否需要在 react-native 应用程序中编写一些代码,而不仅仅是在本机代码中。

Right now, in my react native code I'm using Notifications imported from Expo and I'm using the method Notification.getExpoPushTokenAsync(), but I saw that I should use getDevicePushTokenAsync instead of this, which will return a token, either FCM or APNS.现在,在我的本机代码中,我正在使用从 Expo 导入的通知,并且我正在使用方法 Notification.getExpoPushTokenAsync(),但我看到我应该使用 getDevicePushTokenAsync 而不是 this,它将返回一个令牌,无论是 FCM 还是安息日。 In order to call this method I need to pass it a config, which would be the sender id, but that means that I need to have a firebase project for iOS also?为了调用这个方法,我需要向它传递一个配置,这将是发件人 id,但这意味着我还需要有一个适用于 iOS 的 firebase 项目吗?

TL;DR Can you still use Notifications from Expo with ExpoKit? TL;DR 你还能在 ExpoKit 中使用来自 Expo 的通知吗? If yes, how do you do it?如果是,你怎么做?

If you cannot use them, what are the options for iOS and also Android?如果您不能使用它们,iOS 和 Android 有哪些选择? I saw OneSignal, but it has some legal limitations and FCM does not work with iOS.我看到了 OneSignal,但它有一些法律限制,而且 FCM 不适用于 iOS。

Any input will be much appreciated, thanks!任何输入将不胜感激,谢谢!

I haven't used Expo so I can't answer your first question, but I did have a very good experience with React Native Firebase for both iOS and Android.我没有使用过 Expo,所以我无法回答你的第一个问题,但我确实对 iOS 和 Android 的React Native Firebase有很好的体验。 Here is a great guide on how to get started with notifications .这是有关如何开始使用通知的绝佳指南 Along with notifications React Native Firebase offers many other compelling features such as crash reports, logging, etc.除了通知之外,React Native Firebase 还提供了许多其他引人注目的功能,例如崩溃报告、日志记录等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM