2016-04-05 30 views
0

Push bildirimlerini kullanmak istediğim bir Xamarin.Forms uygulaması var. Mesajı itmek için mobil servisten azure push notification hub'ı kullandım. IOS'ta "Action1" ve "Action2" eylemleriyle etkileşimli bir banner oluşturmak istiyorum. Push mesajı "Action1" ve "Action2" butonu ile alabiliyorum. Ancak bu tuşa dokunmak hiçbir şey yapmaz.Xamarin iOS handleAction Hiçbir zaman arama

yukarıdaki HandleAction yöntemi denir asla alır ve her zaman ReceivedRemoteNotification

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

çağırır

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(); 
} 

Ben farklı türleri:

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(); 
    } 
} 

Ben yöntemle şu var bu işlemek için: Aşağıdaki benim kodudur notificatiosn (örn. basit bir banner bildirimi ve Eylemli bir banner)

Bunun hakkında herhangi bir fikrin var mı? Hala sorun varsa

cevap

0

Bilmiyorum ama işlevini böyle HandleAction yazmaya çalışmalısınız: işe yaradı eğer

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

bana bildirin!