Я успешно интегрировал Sinch SDK, и он отлично работает, когда приложение открыто, теперь я обрабатываю вызов, когда мое приложение находится в автономном режиме.
Используя приведенный ниже метод, я вижу пары push-уведомлений и отправляю эту пару push-уведомлений на сервер для доставки push-уведомлений.
- (void)call:(id<SINCall>)call shouldSendPushNotifications:(NSArray *) pushPairs {
}
В методе didFinishLaunchingWithOptions() Appdelegate.m я получаю полезную нагрузку, специфичную для синча.
NSDictionary* remotePush = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSLog(@"%@",remotePush);
if (remotePush) {
NSLog(@"Entery ****");
// Extract the Sinch-specific payload from the Apple Remote Push Notification
NSString* payload = [[remotePush valueForKey:@"aps"] valueForKey:@"SIN"];
// [[userInfo valueForKey:@"aps"] valueForKey:@"content-available"];
NSLog(@"Payload :%@",payload);
// Get previously initiated Sinch client
id<SINClient> client = _client;
NSLog(@"Client ID %@",[client userId]);
id<SINNotificationResult> result = [client relayRemotePushNotificationPayload:payload];
NSLog(@"Result :%@",result);
if (result.isCall && result.callResult.isTimedOut) {
// Present alert notifying about missed call
} else if (!result.isValid) {
// Handle error
}
}
Вот полные данные Push-уведомления:
{
aps = {
SIN = "AgEBdeibxmJBSK2Y7Nh/fz50VMhVBVQMKzkxODg0NzE4MjQx";
alert = "";
"content-available" = 1;
type = 2;
};
}
Переходя к этому коду:
// Get previously initiated Sinch client
id<SINClient> client = _client;
NSLog(@"Client ID %@",[client userId]);
Когда я печатаю идентификатор клиента, он равен нулю. Как мне получить ранее инициированный клиент Sinch? поскольку приложение закрыто, экземпляр клиента освобождается.