0
當應用程序處於打開狀態時,我已經成功集成了Sinch SDK並且它的工作很好,現在我正在處理應用程序處於脫機狀態時的調用。iOS應用程序在使用APN離線時的Sinch調用
使用下面的方法,我可以看到推對,我將這個推對發送到服務器來推送。
- (void)call:(id<SINCall>)call shouldSendPushNotifications:(NSArray *) pushPairs {
}
在Appdelegate.m didFinishLaunchingWithOptions()方法中,我得到了sinch特定的有效負載。
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
}
}
下面是完整的推送通知的數據:
{
aps = {
SIN = "AgEBdeibxmJBSK2Y7Nh/fz50VMhVBVQMKzkxODg0NzE4MjQx";
alert = "";
"content-available" = 1;
type = 2;
};
}
來到這個代碼:
// Get previously initiated Sinch client
id<SINClient> client = _client;
NSLog(@"Client ID %@",[client userId]);
當我打印客戶端ID是零,我需要怎麼去以前發起的Sinch客戶端?由於App關閉,客戶端實例被釋放。
感謝迅速的回覆,我已經按照你做,現在我可以看到用戶ID,客戶端啓動,但呼叫不中繼。當我打印ID結果= [客戶端RelayRemotePushNotificationPayload:有效載荷]; NSLog(@「Result:%@」,result); 結果:。仍然呼叫不中繼。 –
krish
2014-09-02 07:29:47
@krish我認爲這是一個單獨的問題,但請參閱http://stackoverflow.com/questions/25451427/sinch-calls-via-remote-notification-do-not-start,如果這可能是幫助 – frals 2014-09-02 08:06:48