1.1.0
注意
该门户网站正在开发中.
实现示例
为了了解如何正确集成用于处理 push-通知的包,建议您参阅示例应用程序。
必要条件
为了推送通知的运行,必须遵守以下条件:
- 用户的设备上必须安装 RuStore。
- RuStore 必须支持推送通知功能。
- RuStore 应用程序应允许在后台模式下运行。
- 用户必须在 RuStore 中获得授权。
- 应用程序的签名指纹必须与 RuStore 控制台系统中添加的指纹匹配。
在项目中集成
要将包连接到项目中,需要将其添加到依赖项中:
https://gitflic.ru/project/rustore/defold-extension-rustore-push/file/downloadAll?branch=master
更好的做法是指定特定的发布版本:https://gitflic.ru/project/rustore/defold-extension-rustore-push/release/
初始化
为了初始化 push-通知服务,您需要在项目的 game_project 中添加一个值。使用任何方便的文本编辑器打开它,在 [android] 部分添加
\[android\]rustore_project_id = %your project id%package = %your package%
这里,%your project id% - 项目的标识符,%your package% - Android 包。在开发者控制台,该字段被称为 "项目 ID" 和 "Android Package Name",位于 "Push-通知" -> "项目" 页面。
默认设置的推送消息标题和正文
如果 data 消息中没有,可以为推送通知的标题和正文添加默认值。
\[android\]push_field_title = default push titlepush_field_text = default push body
ndroid 设备上的推送通知服务会自动启动,当调用ruStorePush.set_on_token()
处理 push-token 和消息的方法
获取用户的推送令牌
为获取推送令牌,需要在 ruStorePush.set_on_token() 中添加 callback 到 listener。listenerruStorePush.set_on_token()
如果用户没有推送令牌,该方法将返回一个新的推送令牌。
local function new_token(self, token, error) \`\`if token then \`\`print(token) \`\`else \`\`print(error.error) \`\`endendlocal function push_android() \`\`ruStorePush.set_on_token(new_token)end