Je suis en train de mettre en œuvre les notifications interactives d'Urban Airship, conformément au docs de l'UA. J'ai réussi l'enregistrement catégorie et actions, comme ci-dessous:Objective-C: Action des boutons de la messagerie intégrée à l'application
// Define category options foreground and none
UANotificationActionOptions optionsActions = (UANotificationActionOptionForeground);
UANotificationActionOptions optionsNone = (UANotificationActionOptionNone);
UANotificationCategoryOptions optionCategory = (UANotificationCategoryOptionCustomDismissAction);
// Define cancel action for all categories
UANotificationAction *actionCancel = [UANotificationAction actionWithIdentifier: @"action_cancel"
title: @"Cancel"
options: optionsNone];
// Define post action for the post category
UANotificationAction *actionPost = [UANotificationAction actionWithIdentifier: @"action_post"
title: @"Post"
options: optionsActions];
// Actions of post category
NSArray<UANotificationAction *> *actionsPost = @[actionPost, actionCancel];
// Define the post category
UANotificationCategory *post = [UANotificationCategory categoryWithIdentifier: @"post_cancel"
actions: actionsPost
intentIdentifiers: @[]
options: optionCategory];
// Set the custom categories
[UAirship push].customCategories = [NSSet setWithArray:@[post]];
Maintenant, je suis en train de construire une messagerie In-App avec ces boutons (post & cancel) et mes boutons apparaissent déjà quand je mis buttonGroup du message. Malheureusement, je ne pouvais pas comprendre comment je peux lier des actions personnalisées pour chaque bouton, je ne sais pas quel dictionnaire je devrais passer dans buttonActions du message.
UAInAppMessage *message = [UAInAppMessage new];
message.displayType = UAInAppMessageDisplayTypeBanner;
message.position = UAInAppMessagePositionTop;
message.duration = 5.0;
message.alert = @"My alert"
message.primaryColor = [UIColor whiteColor];
message.secondaryColor = [UIColor blackColor];
UAInAppMessaging *inAppMessaging = [UAInAppMessaging new];
[message setButtonGroup: @"post_cancel"]; // this line ensure that my in-app messaging add my two registered buttons
[message setButtonActions: /* WHICH DICTIONARY SHOULD I PASS? */ ];
dispatch_async(dispatch_get_main_queue(), ^{
[inAppMessaging displayMessage: message];
});
Merci.
Nice! Cela a fonctionné, merci! –