From cfb8f3fe411693ea694c315442862eb2fb11437b Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Sat, 26 Dec 2020 23:22:27 +0800 Subject: [PATCH] Add push payload format to README.md. --- README.md | 19 +++++++++++++++++ ios/Classes/CallKeep.m | 46 ++++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 923a157..6614c5c 100644 --- a/README.md +++ b/README.md @@ -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", + } +} +``` diff --git a/ios/Classes/CallKeep.m b/ios/Classes/CallKeep.m index eb1dca4..cd590d6 100644 --- a/ios/Classes/CallKeep.m +++ b/ios/Classes/CallKeep.m @@ -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:^(){}];