Skip to content

Commit cfb8f3f

Browse files
committed
Add push payload format to README.md.
1 parent b3dd0b2 commit cfb8f3f

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
# callkeep
2+
23
* iOS CallKit and Android ConnectionService for Flutter
34
* Support FCM and PushKit
5+
6+
## push payload
7+
8+
```json
9+
{
10+
"callkeep": {
11+
"uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
12+
"caller_id": "+8618612345678",
13+
"caller_name": "hello",
14+
"caller_id_type": "number",
15+
"has_video": false,
16+
},
17+
"extra": {
18+
"foo": "bar",
19+
"key": "value",
20+
}
21+
}
22+
```

ios/Classes/CallKeep.m

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -224,32 +224,38 @@ - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayloa
224224
// Process the received push
225225
NSLog(@"didReceiveIncomingPushWithPayload payload = %@", payload.type);
226226
/* payload example.
227-
{
228-
"callkeep": {
229-
"caller_id": "+8618612345678",
230-
"caller_name": "hello",
231-
"caller_id_type": "number",
232-
"has_video": false,
233-
},
234-
"extra": {
235-
"foo": "bar",
236-
"key": "value",
237-
}
238-
}
227+
{
228+
"callkeep": {
229+
"uuid": "xxxxx-xxxxx-xxxxx-xxxxx",
230+
"caller_id": "+8618612345678",
231+
"caller_name": "hello",
232+
"caller_id_type": "number",
233+
"has_video": false,
234+
},
235+
"extra": {
236+
"foo": "bar",
237+
"key": "value",
238+
}
239+
}
239240
*/
240241
NSDictionary *dic = payload.dictionaryPayload[@"callkeep"];
241-
NSString *number = dic[@"caller_id"];
242-
NSString *localizedCallerName = dic[@"caller_name"];
242+
NSString *callerId = dic[@"caller_id"];
243+
NSString *callerName = dic[@"caller_name"];
243244
BOOL hasVideo = [dic[@"has_video"] boolValue];
244-
NSString *handleType = dic[@"caller_id_type"];
245-
245+
NSString *callerIdType = dic[@"caller_id_type"];
246+
NSString *uuid = dic[@"uuid"];
247+
248+
if( uuid == nil) {
249+
uuid = [self createUUID];
250+
}
251+
246252
//NSDictionary *extra = payload.dictionaryPayload[@"extra"];
247253

248-
[CallKeep reportNewIncomingCall:[self createUUID]
249-
handle:number
250-
handleType:handleType
254+
[CallKeep reportNewIncomingCall:uuid
255+
handle:callerId
256+
handleType:callerIdType
251257
hasVideo:hasVideo
252-
localizedCallerName:localizedCallerName
258+
localizedCallerName:callerName
253259
fromPushKit:YES
254260
payload:payload.dictionaryPayload
255261
withCompletionHandler:^(){}];

0 commit comments

Comments
 (0)