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.
