River documentation

River documentation

  • Documentation
  • Blog

›PUSH-notifications

User Authorization

  • User Authorization

Error Handling

  • Error Handling

PUSH-notifications

  • Handling PUSH-notifications

Handling Updates

  • Handling Updates

Pagination

  • Pagination

Message Drafts

  • Message Drafts

Encryption

  • Encryption

API methods

  • Available method list

Client Optimization

  • Client Optimization

Uploading and Downloading

  • Uploading and Downloading

Handling PUSH-notifications

Push Notification Handling Mechanism:

The River push notification mechanism is explained as follows: When a client sends a request to the edge server, this request will be kept in there. Next, it should be prepared to transfer to the receiver device. Moreover, a notification will be generated by the bellow code. After, it will be transmitted to the notification server. Immediately, it is time to send this notification to the Apple Push Notification Services APNS and Apple PushKit for iOS or Firebase Cloud Messaging FCM for Android depending on the receiver's operating system. As mentioned above, now it is the mobile notification services turn. These services allow third-party app developers to send information from their servers to the user's devices.

Subscribing to notifications

The client must invoke the account.registerDevice query to register users' devices to receive notifications. This method passes the device token as token parameter that identifies the current device. This calling will repeat when the application has been restarted. If a user mutes its notifications, account.unregisterDevice method will be called to delete a device by its token to stop receiving notifications.

Notification structure

A notification is produced as a JSON object in the following format:

{
     "tmpls" : {
       "en" : {
         "title" : "New Message",
         "body" : "%s : %s"
       },
       "fa" : {
         "title" : "پیام جدید",
         "body" : "%s: %s"
       }
     },
     "type" : 1
   },

There are several parameters that describe a notification.

Notification Parameters

  • title: The title of a notification
  • body: The content of a notification
  • type: Notification types are defined as a constant number to make them different, as you will see follow;
MessageText = iota + 1 : 1
MessagePhoto : 2
MessageGeoLocation: 3
MessageDoc : 4
MessageContact : 5
MessageDeleted : 6
ContactJoined : 7
GroupMessageText : 8
GroupMessageGeoLocation : 9
GroupMessageDoc : 10
GroupMessageContact : 11
GroupMentioned : 12
GroupCreated : 13
GroupAdded : 14
GroupAddedYou : 15
GroupRemoveMember : 16
GroupRemoveYou : 17
GroupLeft : 18
GroupReturned : 19
ReadHistory : 20
ReadChannelHistory : 21

Service Notifications

The following notifications can be used to update app settings.

  • New Message | پیام جدید
  • New Photo Message | پیام جدید
  • sent a location | مختصات ارسال کرد
  • New Doc Message | داکیومنت ارسال کرد
  • New Contact Message | مخاطب ارسال کرد
  • Joined River | عضو ریور شد
  • New Group Message | پیام جدید گروه
  • Location | مختصات ارسال کرد
  • New Group Doc Message | داکیومنت ارسال کرد
  • New Group Contact Message | مخاطب ارسال کرد
  • Group Created | گروه ساخته شد
  • Group Add Member | عضو جدید گروه
  • Group Add You | عضو گروه
  • Group Remove Member | حذف عضو گروه
  • Group Remove You | حذف از گروه
  • Group Left | ترک گروه
  • Group Returned | بازگشت گروه
← Error HandlingHandling Updates →
  • Push Notification Handling Mechanism:
    • Subscribing to notifications
    • Notification structure
    • Notification Parameters
    • Service Notifications
Copyright © 2020 RonakSoftwareGroup