如何解决如何使用Flutter Huawei Push Kit插件获取推送通知单击事件?
我将Fluke应用程序中集成了华为Push Kit(https://pub.dev/packages/huawei_push),并且一切正常,除了单击接收到的推送通知消息以对其进行操作时无法获取事件之外。
是否可以通过此插件实现?还是需要用本机Android代码编写此部分?
解决方法
当前,您可以使用另一个监听自定义意图的插件来实现。来自pub.dev的Uni_links软件包易于使用。这是uni_links软件包的快速指南:
- 将 uni_links 添加到您的 pubspec.yaml 文件中:
with x as (select 'in' Diff_Ins union select 'In' Diff_Ins)
select Diff_Ins from x where Diff_Ins REGEXP '\bIn\b';
- 在 AndroidManifest.xml 文件上定义一个意图过滤器:
dependencies:
flutter:
sdk: flutter
huawei_push: 4.0.4+300
uni_links: 0.4.0
- 在initState()中调用uni链接方法,该方法将侦听自定义意图。我从Push Kit控制台发送的通知的自定义意图如下所示:
<application
<!-- . . . Other Configurations . . . -->
<activity/>
<!-- . . . Other Configurations . . . -->
<!-- Add the intent filter below.(inside the application and activity tags) -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="app"/>
</intent-filter>
</activity>
</application
app:///ContentPage?name=Push Kit&url=https://developer.huawei.com/consumer/en/hms/huawei-pushkit
有关更多信息,请访问:Deep Linking on Flutter using Huawei Push Kit’s Custom Intents 本文的accompanying github repository包含代码。
,我也研究了他们的flutter插件,对此没有任何方法。我猜您将不得不编写平台特定的代码,为此,您可以使用PushKit引用他们的演示本机android项目。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。