1.0.0
注意
该门户网站正在开发中。文档的完整版本请看这里.
实现示例
请参阅示例应用程序,了解如何正确集成用于处理 push 通知的包:https://gitflic.ru/project/rustore/flutter-rustore-push
推送通知的运行条件
为了推送通知的运行,必须遵守以下条件:
- 用户的设备上必须安装 RuStore 应用程序。
- RuStore 应用程序必须支持推送通知的功能。
- RuStore 应用程序应允许在后台模式下运行。
- 用户必须在 RuStore 应用程序中获得授权。
- 应用程序的签名指纹必须与 RuStore 控制台中添加的指纹匹配。
在项目中集成
要将包集成到项目,请执行以下命令:
flutter pub add flutter_rustore_push
个命令将在 pubspec.yaml 文件中添加一个字符串。
dependencies: \`\`flutter_rustore_push: \^1.0.0
初始化
为了初始化推送通知服务,请在您的 android 项目的 values 中添加值:
\<resources\> \`\`\<string name= \"flutter_rustore_push_project\" translatable= \"false\" \>xxx\</string\>\</resources\>
xxx - 这是项目标识符。在 RuStore 控制台系统中,该字段被称为"项目 ID",位于"推送通知 -> 项目"部分。
要启动推送通知服务,需要添加一个从 FlutterRustoreApplication 继承的 Application 类。
在 Kotlin 中这样做的例子:
package ru.rustore.flutter_rustore_push_exampleimport ru.rustore.flutter_rustore_push.FlutterRustoreApplicationopen class Application: FlutterRustoreApplication() {}
AndroidManifest.xml 中需要指定这个类:
\<application \`\`android:label= \"flutter_rustore_push_example\" \`\`android:name= \".Application\" \`\`android:icon= \"@mipmap/ic_launcher\" \> \`\`// \... \`\`\</application\>
设置ProGuard
要配置 ProGuard,请添加以下规则:
android/app/build.gradle 文件中添加:
```JavaScript
buildTypes { \`\`release { \`\`// \... \`\`proguardFiles getDefaultProguardFile( \'proguard-android.txt\' ), \'proguard-rules.pro\' \`\`} \`\`// \...}
检查获得推送通知的可能性
为了推送通知的运行,必须遵守几个条件:
- 用户的设备上必须安装 RuStore。
- RuStore 必须支持推送通知功能。
- RuStore 应用程序应允许在后台模式下运行。
- 用户必须在 RuStore 中获得授权。
检查上述条件,可以使用 RustorePushClient.available() 方法:
RustorePushClient.available().then((value) { \`\`print( \"available success: \${value}\" );}, onError: (err) { \`\`print( \"available error: \${err}\" );});