0.6.1
注意
该门户网站正在开发中。文档的完整版本请看这里.
为了推送通知的运行,必须遵守以下条件:
- 用户的设备上必须安装 RuStore。
- RuStore 必须支持推送通知功能。
- RuStore 应用程序应允许在后台模式下运行。
- 用户必须在 RuStore 中获得授权。
- 应用程序的签名指纹必须与 RuStore 控制台中添加的指纹匹配。
在项目中集成
要集成,请下载RuStorePush SDK并将其导入项目(Assets → Import Package → Custom Package)。依赖项将通过SDK中包含的External Dependency Manager自动连接。
MinimumAPIlevel应设置为不低于24。应用程序的缩 减(ProGuard/R8)目前不受支持,因此需要在项目设置中将其关闭(File → Build Settings → Player Settings → Publishing Settings → Minify)。
编辑应用程序清单
您必须声明 RuStoreUnityMessagingService 服务:
\< service \`\`android:name = \"ru.rustore.unitysdk.pushclient.RuStoreUnityMessagingService\" \`\`android:exported = \"true\" \`\`tools:ignore = \"ExportedService\" \> \`\`\< intent-filter \> \`\`\< action android:name = \"ru.rustore.sdk.pushclient.MESSAGING_EVENT\" /\> \`\`\</ intent-filter \>\</ service \>
果您想更改标准通知的图标或颜色,可以添加以下元数据:
\< meta-data \`\`android:name = \"ru.rustore.sdk.pushclient.default_notification_icon\" \`\`android:resource = \"@drawable/ic_baseline_android_24\" /\>\< meta-data \`\`android:name = \"ru.rustore.sdk.pushclient.default_notification_color\" \`\`android:resource = \"@color/your_favorite_color\" /\>
可以添加以下元数据以重写通知渠道:
\< meta-data \`\`android:name = \"ru.rustore.sdk.pushclient.default_notification_channel_id\" \`\`android:value = \"@string/pushes_notification_channel_id\" /\>
您添加自己的推送通知渠道时,您需要自行创建该渠道。
初始化
为了初始化,需要在项目中重写 Application 类。所需的源代码已包含在文件 Assets/RuStoreSDK/PushClient/Android/RuStoreUnityApplication.java 中:
package ru.rustore.unitysdk;import android.app.Application;import ru.rustore.unitysdk.pushclient.RuStoreUnityPushClient;public class RuStoreUnityApplication extends Application { \`\`@Override public void onCreate() { \`\`super .onCreate(); \`\`RuStoreUnityPushClient.init( \`\`application = this \`\`); \`\`}}
application
- Application类的实例。
要在项目的 AndroidManifest.xml 中指定这个类:
\< application android:name = \"ru.rustore.unitysdk.RuStoreUnityApplication\" \>
将使用在Unity编辑器中设置的参数进行初始化。在编辑器菜单中选择Window → RuStoreSDK → Settings → Push Client:
VKPNSProjectId
- 您在 RuStore 开发者控制台中项目的标识符;AllowAllow Native Error Handling
- 允许原生 SDK 中的错误处理。错误处理
从 C#### 代码中调用库方法之前,必须先调用它的初始化:
var сonfig = new RuStorePushClientConfig() { \`\`allowNativeErrorHandling = true , \`\`messagingServiceListener = pushServiceListener, \`\`logListener = pushLogListener};RuStorePushClient.Instance.Init(сonfig);
allowallowNativeErrorHandling
- 允许原生 SDK 中的错误处理;错误处理messagingServiceListener
- 实现 IMessagingServiceListener 接口的类对象;logListener
- 实现 ILogListener 接口的类对象。