Push Notifications
Direct Push Notifications
With this solution the notifications will be triggered and delivered to your users directly by Amity's servers. There's nothing that the Android client has to do in order to display the notification to your users. Amity's servers will prepare for you a notification that can be directly displayed to the user as and when it's received.
Setup Push Notification Certificate.
In order for Amity's server to start sending push notification to the Android client , You need to prepare the Firebase certification (for the device that support by google push notification service) Or Baidu cloud Push certification(for the device not support by google service) and uploaded to Amity system via Amity Admin panel.
Push Notification Triggers
A new push notification will be sent to a specific user when the following event happens IN a community user a member.
A new post has been created in the community user is a member.
Post owner has been reacted by a user in the community
Post owner has new Comment created by a user in the community.
Comment or Reply owner has been reacted by a user in the community
Comment owner has a new Reply created by a user in the community.
Push Notification Examples
As Amity's servers are responsible for choosing the content of the push notification, you can expect your users to receive the following notifications for different kind of events:
A new post has been created in the community user is a member.
Title : CommunityDisplayname
Body : userDisplayname
created new post in your community.
Post owner has been reacted by a user in the community
Title : CommunityDisplayname
Body : userDisplayname
reacted to your post
Post owner has new Comment created by a user in the community.
Title : CommunityDisplayname
Body : userDisplayname
commented to your post
Comment or Reply owner has been reacted by a user in the community
Title : CommunityDisplayname
Body : userDisplayname
reacted to your comment
Comment owner has a new Reply created by a user in the community.
Title : CommunityDisplayname
Body : userDisplayname
replied to your comment
Push Notification context customization
as default, all the event related to the Community feature has default context base on each event trigger, to customize the context for each event, you can access to Admin panel to do so.
Client Push Notification Toggles
The SDK has three levels of notifications and in order for it to be sent, a notification has to pass throughout all three levels.
Network Level: (via Admin Panel) turning off notifications at this level effectively disable push notifications altogether for all of your customers.
User Level: (via client) A user can choose to enable/disable the notifications that it receives on the device (this is an absolute option: enable all or disable all). Please note that this setting is per user, not per device: regardless of which device sets this toggle, the new preference will take effect in all the devices where the user is logged in.
Community Level: (via client) A user can choose to enable/disable notifications for a specific community (where is member of). Again, this preference is per user, not per device.
please note that if the Network level has been disable , the event in the User level AND Community level will be disabled as well.
Client Registration
The first step of receiving the Push notification is start with the following step
Initialize Push Notification
FCM dependency:
Before you can start receiving push notifications, you need to obtain a FCM unique token string that identifies each FCM client app instance:
You can initialize the services with the obtained token. Please note that the FCM token can be changed through application life cycle. Please make sure that the FCM token supplied to the messaging SDK is up to date. To notify the messaging SDK of the latest token, the following line of code can be called whenever necessary:
Push Notification In China
Since Google play services are banned in China, The messaging SDK provides Baidu push services as a substitute for FCM. The messaging SDK requires an api key and a secret key from Baidu:
Baidu dependency:
Note: Baidu push services require number of additional permissions. You can find a list of permissions here.
Baidu API key is needed for Baidu push services initialization:
Note: The messaging SDK always consider FCM as a primary push provider and Baidu as a secondary push provider. If the messaging SDK detects Google play services on the device, Baidu push services won't be initialized.
Registration
The registration will automatically pick up the active userId
, and Amity's back-end will start sending push notifications to the particular user. In the where the active userId
has been changed, registration will be required again.
Registering your app for push notification will require a registered EkoClient
instance (necessary to know which user is associated with this device) and a push notification token.
Amity's Development Kit does not manage:
user-facing requests for push notifications and authorizations
the creation and refreshing of push notification tokens
It's up to your app to take those steps and pass the notification token to the SDK.
We recommend to observe the completion block outcome to assure of a successful registration.
If the device was previously registered with this or another user, the previous registration is invalidated as soon as this new request is received, which means that the device will always receive notifications of up to one user.
Community Level Push Notification Toggle
Setting Community Push Notifications
For community preferences we use the EkoCommunityRepository
, obtained via instance of EkoCommunityRepository
:
Getting Community Push Notifications
User Level Push Notification Toggle
Setting User Push Notifications
For user preferences we use the EkoClient
, obtained via instance of EkoClient
:
User Push Notifications
Client Unregistration
Unlike the registration, unregistering for push does not require the EkoClient
instance to be associated with any user, therefore you can unregister the device from receiving push notifications as soon as the EkoClient
has been initial
Last updated