Skip to content

Commit

Permalink
Add push payload format to README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Dec 26, 2020
1 parent b3dd0b2 commit cfb8f3f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 20 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# callkeep

* iOS CallKit and Android ConnectionService for Flutter
* Support FCM and PushKit

## push payload

```json
{
"callkeep": {
"uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
"caller_id": "+8618612345678",
"caller_name": "hello",
"caller_id_type": "number",
"has_video": false,
},
"extra": {
"foo": "bar",
"key": "value",
}
}
```
46 changes: 26 additions & 20 deletions ios/Classes/CallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,32 +224,38 @@ - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayloa
// Process the received push
NSLog(@"didReceiveIncomingPushWithPayload payload = %@", payload.type);
/* payload example.
{
"callkeep": {
"caller_id": "+8618612345678",
"caller_name": "hello",
"caller_id_type": "number",
"has_video": false,
},
"extra": {
"foo": "bar",
"key": "value",
}
}
{
"callkeep": {
"uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
"caller_id": "+8618612345678",
"caller_name": "hello",
"caller_id_type": "number",
"has_video": false,
},
"extra": {
"foo": "bar",
"key": "value",
}
}
*/
NSDictionary *dic = payload.dictionaryPayload[@"callkeep"];
NSString *number = dic[@"caller_id"];
NSString *localizedCallerName = dic[@"caller_name"];
NSString *callerId = dic[@"caller_id"];
NSString *callerName = dic[@"caller_name"];
BOOL hasVideo = [dic[@"has_video"] boolValue];
NSString *handleType = dic[@"caller_id_type"];

NSString *callerIdType = dic[@"caller_id_type"];
NSString *uuid = dic[@"uuid"];

if( uuid == nil) {
uuid = [self createUUID];
}

//NSDictionary *extra = payload.dictionaryPayload[@"extra"];

[CallKeep reportNewIncomingCall:[self createUUID]
handle:number
handleType:handleType
[CallKeep reportNewIncomingCall:uuid
handle:callerId
handleType:callerIdType
hasVideo:hasVideo
localizedCallerName:localizedCallerName
localizedCallerName:callerName
fromPushKit:YES
payload:payload.dictionaryPayload
withCompletionHandler:^(){}];
Expand Down

0 comments on commit cfb8f3f

Please sign in to comment.