简体   繁体   English

将 OneSignal 与 Flutter 结合使用

[英]Using OneSignal with Flutter

I notice that I can use Firebase for push notification feature.我注意到我可以将 Firebase 用于推送通知功能。 But my project requires using OneSignal.但是我的项目需要使用 OneSignal。 Is it possible to achieve it in Flutter?是否有可能在 Flutter 中实现? I can't find any post nor article talking about that.我找不到任何帖子或文章谈论这个。

Thanks.谢谢。

EDIT:编辑:

There is an official plugin now for OneSignal https://github.com/OneSignal/OneSignal-Flutter-SDK OneSignal 现在有一个官方插件https://github.com/OneSignal/OneSignal-Flutter-SDK


Unfortunately, there is no plugin for flutter to use OneSignal.不幸的是,flutter 没有使用 OneSignal 的插件。 You can write one yourself , though.不过你可以自己写一个

Since OneSignal exists for iOS and Android, what you have to do is write a communication between flutter and respective platforms.由于 OneSignal 存在于 iOS 和 Android 上,您需要做的是在 Flutter 和各自平台之间编写通信。

If you decide to just implement the features for yourself, even pure platform channels can be viable.如果您决定只为自己实现这些功能,那么即使是纯平台渠道也是可行的。

Flutter plugin is just a wrapper to extract usage of platform channel that are platform dependent into a library. Flutter 插件只是一个包装器,用于将平台相关的平台通道的使用提取到库中。

IF you are using IntelliJ, after starting with plugin template on new project, in Tools -> Flutter you have an option to open the native iOS/Android code in Xcode/Android Studio.如果您使用 IntelliJ,在新项目上使用插件模板开始后,在 Tools -> Flutter 中,您可以选择在 Xcode/Android Studio 中打开本机 iOS/Android 代码。 That should help to start things up.这应该有助于开始工作。

打开

There is an official Flutter package !有一个官方的Flutter 包

Add it as a dependency to your pubspec.yaml file:将其作为依赖项添加到pubspec.yaml文件中:

dependencies:
  onesignal_flutter: ^2.6.2  # Verify that this is the latest version

Full setup instructions can be found here .可以在此处找到完整的设置说明。

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

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