私は Sinch SDK を正常に統合し、アプリが開いているときにうまく機能し、アプリがオフラインのときに呼び出しを処理しています。
以下の方法を使用してプッシュペアを確認でき、このプッシュペアをサーバーに送信してプッシュを配信しています。
- (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を印刷すると、それはNilです。以前に開始されたSinchクライアントを取得するにはどうすればよいですか? アプリが閉じているため、クライアント インスタンスは解放されます。