2016-04-05 6 views
0

プッシュ通知を使用するXamarin.Formsアプリがあります。私はメッセージをプッシュするために、モバイルサービスからの空白のプッシュ通知ハブを使用しました。私はiOS上で何らかのアクション "Action1"と "Action2"を持つインタラクティブなバナーを作りたいと思っています。私は "Action1"と "Action2"ボタンでプッシュメッセージを受け取ることができます。しかし、そのボタンをタップすることは何もしません。Xamarin iOS handleAction never call

上記 HandleActionメソッドが呼び出されることはありません取得し、それが常に ReceivedRemoteNotification

public override async void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) 
{ 
    ProcessNotification (userInfo, false); 
} 

を呼び出し

public override void HandleAction (UIApplication application, string actionIdentifier, NSDictionary remoteNotificationInfo, Action completionHandler) 
{ 
    if (actionIdentifier.Equals ("ACCEPT_IDENTIFIER")) { 
     //var alert = notification.AlertBody; 
     //new UIAlertView ("Msg", alert, null, "OK", null).Show(); 
     //NotificationHelper.ReceivePushMessage (alert); 
     ProcessNotification (remoteNotificationInfo, false); 
    } 
    UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; 
    completionHandler(); 
} 

私が持っているさまざまな種類:

private static void RegisterPushAction() 
{ 
    UIMutableUserNotificationAction acceptAction = new UIMutableUserNotificationAction(); 
    acceptAction.Title = "Action1"; 
    acceptAction.Identifier = "ACCEPT_IDENTIFIER"; 
    acceptAction.ActivationMode = UIUserNotificationActivationMode.Background; 
    acceptAction.Destructive = false; 
    acceptAction.AuthenticationRequired = false; 

    UIMutableUserNotificationAction denyAction = new UIMutableUserNotificationAction(); 
    denyAction.Title = "Action2; 
    denyAction.Identifier = "DENY_IDENTIFIER"; 
    denyAction.ActivationMode = UIUserNotificationActivationMode.Background; 
    denyAction.Destructive = false; 
    denyAction.AuthenticationRequired = false; 

    UIMutableUserNotificationCategory acceptCategory = new UIMutableUserNotificationCategory(); 
    acceptCategory.Identifier = "JOIN_CATEGORY"; 
    acceptCategory.SetActions (new UIUserNotificationAction[]{acceptAction,denyAction}, UIUserNotificationActionContext.Default); 

    NSSet categories = new NSSet (acceptCategory); 
    //iOS 7 
    if (Convert.ToInt16 (UIDevice.CurrentDevice.SystemVersion.Split ('.') [0].ToString()) < 8) { 
     UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; 
     UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes); 
    } else { 
     UIUserNotificationType types = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound; 
     UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes (types, categories); 
     UIApplication.SharedApplication.RegisterUserNotificationSettings (settings); 
     UIApplication.SharedApplication.RegisterForRemoteNotifications(); 
    } 
} 

は、私は方法以下している、これを処理するには、次は私のコードです(例えば、単純なバナー通知とバナーとアクション)

これについてのご意見はありますか?

答えて

0

あなたはまだ問題を抱えていますが、このように機能HandleActionを書いてみるべきかどうかはわからない:

public override void HandleAction (UIApplication application, String actionIdentifier, NSDictionary remoteNotificationInfo, NSDictionary responseInfo, Action completionHandler) 

は、それが働いていた場合、私に教えてください!