Basim Alamuddin
Basim Alamuddin

Reputation: 188

Sinch call headers are received in the push payload but are nil in the call object

I'm sending the caller full name in Sinch call headers to be displayed in the callkit native screen when the call is received.

I have checked the data and it's received in the push payload in this function

- (void)managedPush:(id<SINManagedPush>)managedPush
    didReceiveIncomingPushWithPayload:(NSDictionary *)payload
                              forType:(NSString *)pushType;

But when accessing the call headers from

- (void)client:(id<SINCallClient>)client willReceiveIncomingCall:(id<SINCall>)call;

when calling call.headers the dictionary is empty!

Upvotes: 0

Views: 403

Answers (1)

Bo Li
Bo Li

Reputation: 181

It is possible to set some header(s) in the Push Notification when making a call via

id<SINCall> call = [self.callClient callUserWithId:userid headers:header];

On the receiving side, before you relay the received push notification to Sinch Client for further process. The headers you set on the caller side will also be contained in the query result:

- (void)managedPush:(id<SINManagedPush>)unused
    didReceiveIncomingPushWithPayload:(NSDictionary *)payload
                              forType:(NSString *)pushType {

  id<SINNotificationResult> result = [SINPushHelper queryPushNotificationPayload:payload];
  if(result.isCall) {
    _callKitProvider.remoteDisplayName = result.callResult.headers[@"display_name"];
    NSLog(@"display_name: %@", _callKitProvider.remoteDisplayName);
  }
  [self handleRemoteNotification:payload];
}

I attached an git diff file here to show the changes needed to include a customized display name in the header of the push message from the caller, and show it on callkit screen on callees's device, the diff is based on the callkit sample app from Sinch SDK package.

Upvotes: 3

Related Questions