推送通知服务
推送通知 (Push Notifications) 服务用于向用户发送有关 RainMaker 的事件通知。在安卓和 iOS 中使用这一服务分别需要在通知设置中配置 FCM 和 APNS 环境。
在安卓中配置推送通知服务
-
为安卓应用配置推送通知服务,请参阅推送通知设置。
-
前往 Firebase 控制台选择您的项目。在左侧导航栏中点击齿轮图标,然后选择
Project settings。
-
前往
Service accounts,点击Generate new private key,请将其复制到剪贴板。
-
用管理员账号登录 RainMaker 管理面板。打开
Deployment Settings>Push Notifications。
-
创建新的平台应用程序。选择类型为
Google Notification。
-
输入步骤 3 复制的整个文件内容,点击
Save。
-
现在可以启用推送通知服务了,具体启用步骤请参阅启用通知推送。
Android App Code Level Configurations
-
Your android application must be registered with Firebase for push notifications to work. You can Register using these steps if not done already.
-
Click
Download google-services.jsonto obtain your Firebase Android config file (google-services.json). Replace existinggoogle-services.jsonfile with your downloaded file in the app module (app-level) directory of your app.
-
Keep the remaining settings as it is.

-
Continue with the Push Notifications Configuration.
Firebase Settings
To configure this further, you must log in with your Google account on the Firebase console.
Create a Firebase project
-
In the Firebase console, click
Create a project, then select or enter aProject name.

If you have an existing Google Cloud project, you can select the project from the dropdown menu to add Firebase resources to that project.
- (Optional) If you are creating a new project, you can edit the
Project ID. To use a specific identifier, you must edit your project ID during this setup step. Firebase automatically assigns a unique ID to your Firebase project.
After Firebase provisions resources for your Firebase project, you cannot change your project ID.
-
Click
Continue.
-
Click
Create project(orAdd Firebaseif you're using an existing Google Cloud project).
For more information, see Create a Firebase project on the Firebase website.
Register your app with Firebase
To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.
Visit Understand Firebase Projects to learn more about best practices and considerations for adding apps to a Firebase project, including how to handle multiple build variants.
-
Go to the Firebase console.
-
In the centre of the
Project Overviewpage, click the Android icon (plat_android) orAdd an app to get startedto launch the setup workflow.
-
Enter your app's package name (application id) in the
Android package name field. ClickRegister app.
备注Make sure to enter the package name that your app is using. The package name value is case-sensitive, and cannot be changed for this Firebase Android app after registering with your Firebase project.
备注For more information, see Register your app on the Firebase website.
在 iOS 中配置推送通知服务
-
登录苹果开发者账号。

-
启用此服务需要用 App ID。若尚未创建,请前往 Apple Developer 控制台创建新账号,具体步骤请参阅在苹果开发者控制台创建应用 ID。
-
打开
Certificates一栏,点击+。
-
为推送通知服务创建新的证书,请选择
Apple Push Notification service SSL (Sandbox & Production)并点击Continue。
-
选择应用程序的 App ID 并点击
Continue。
-
接下来需要创建
Certificate signing request (CSR)。
-
打开
Keychain Access工具栏,选择Certificate Assistant>Request a certificate from a Certificate Authority。
-
在
Certificate Assistant对话框中,找到User Email Address一栏并输入电子邮件地址,CA Email Address一栏无需填写。选择Saved to disk并点击Continue以保存证书。
-
上传 CSR。

-
证书已经成功创建,可以使用
Keychain Access下载并查看。
-
从
Keychain Access导出证书,格式为p12。
无需设置密码来保护导出的证书。

-
启动通知推送需要 SSL Certificate 和 Private Key。 使用以下命令可获取 SSL Certificate。
openssl pkcs12 -in yourP12Certificate.p12 -clcerts -nokeys
使用以下命令可获取 Private Key。
openssl pkcs12 -in yourP12Certificate.p12 -nocerts -nodes
-
用管理员账号登录 RainMaker 管理面板。打开
Deployment Settings>Push Notifications。
-
创建新的平台应用程序,选择类型为
Apple Notification (APNS)。
-
将步骤 12 中获取的 SSL Certificate 和 API Key 粘贴至此处,点击
Save。
备注该证书也可用于沙盒和生产环境。沙盒环境用于测试通知和调试,APNS 用于分发。您可以重复步骤 13 和 14,选择类型为
APNS_SANDBOX,为沙盒环境设置推送通知。 -
现在可以启用推送通知服务了,具体启用步骤请参阅启用通知推送。