Chat Doc

step 1 Delcare & obtain

Client declare
token: current device token
address: WOW wallet address non_null
externalId: push notification user's externalId, nullable, if user denied the push notification permission, value will be ''

NSDictionary *d = @{@"address":@"0xXXXXXX",@"token":@"eyXXXXXXXX",@"externalId":""};
NSString *jsonStr = [d mj_JSONString];
[@"window.clientInfo={};window.clientInfo='%@'",jsonStr]

Web obtain

let info = JSON.parse(JSON.stringify(window.clientInfo));

step 2 Web notify client

Web team should provide unread number of messages once you received it.
Then Client could show red dot at tabbar to remind user.
You can use func below to provide data, that means there was 2 unread msg.

// iOS
window.webkit.messageHandlers.updateUnreadNum.postMessage('2');
// Android
window.android.updateUnreadNum('2');

the updateUnreadNum is a func that client team declared, you shouldn't call func like postMessage(), it must contain data even empty string or null.

step 3 push notification

REST API of OneSignal
App ID should be found in dashboard of onesignal

step 4 add/create/delete/switch wallet

  • add/create/switch wallet are same to client, client would released the chat and reloaded it, so web side can always obtain the latest data, like token externalId address. Web should refresh this three datas and bind them.
  • delete wallet has two situation

    there is only one wallet, if deleted it , there's no wallet in app, so client should notify web refresh the state that do not push notifications to this device if the permission is accept.

  • there are more than one wallet in app, if deleted one of them, client shouldn't notify web, this situation like switch wallet.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容