コメント
コメントの投稿
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。
using PushKit;
using CoreFoundation;
using Amazon;
using Amazon.CognitoIdentity;
using Amazon.SimpleNotificationService;
using Amazon.SimpleNotificationService.Model;
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//PKPushRegistryDelegateから呼び出しできるように
public static AmazonSimpleNotificationServiceClient SnsClient = null;
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
//VoIPの設定
PKPushRegistry voipReg = new PKPushRegistry(DispatchQueue.MainQueue);
voipReg.Delegate = new VoIPRegistryDelegate();
voipReg.DesiredPushTypes = new NSSet(new string[] { PKPushType.Voip });
//AWS
this.SetAmazonSnsSettings();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
#region "VoIP"
public class VoIPRegistryDelegate : PKPushRegistryDelegate
{
public override void DidReceiveIncomingPush(PKPushRegistry registry, PKPushPayload payload, string type)
{
// VoIPプッシュ通知を受けたときの処理
if (UIApplication.SharedApplication.ApplicationState == UIApplicationState.Background)
{
//アプリが起動していない場合にバックグラウンド処理を実行する
AppDelegate.BackgroundService();
}
}
public override void DidUpdatePushCredentials(PKPushRegistry registry, PKPushCredentials credentials, string type)
{
// デバイストークンをプッシュ通知サーバに登録する処理
if (credentials != null &&
credentials.Token != null &&
!String.IsNullOrEmpty(credentials.Token.ToString()))
{
string token = credentials.Token.ToString();
token = token.Trim('<').Trim('>').Replace(" ", "");
//register with SNS to create an endpoint ARN
var response = AppDelegate.SnsClient.CreatePlatformEndpointAsync(
new CreatePlatformEndpointRequest
{
Token = token,
PlatformApplicationArn = "arn:aws:sns:us-west-9:999999999999:app/APNS_VOIP_SANDBOX/AppName_VoIP"
});
}
}
}
#endregion
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。