Search code examples
apple-push-notificationspushsharp

Push sharp Notification with Title and View Close Buttons


I am using push sharp to create remote notification. But I get the notification with out a title and a View/Close buttons.

I am using a code adapted from Here

Here is how I create my alert

    AppleNotificationAlert alert = new AppleNotificationAlert();
    alert.ActionLocalizedKey = "View Alert";
    alert.Body = message;
    alert.AddLocalizedArgs(new object[] { "title", "Test Title"});
    pushBroker.QueueNotification(new AppleNotification()    .ForDeviceToken(deviceToken).WithAlert(alert).WithBadge(1).WithSound("sound.caf").WithCustomItem("level", level).WithContentAvailable(1));

I also tried just specifying the Alert body as follows but it does not show View/Close buttons

 pushBroker.QueueNotification(new AppleNotification()    .ForDeviceToken(deviceToken).WithAlert("Alert Body").WithBadge(1).WithSound("sound.caf").WithCustomItem("level", level).WithContentAvailable(1));

Solution

  • Your code is right. I just spinned it out and it worked ! In your IOS device settings choose your app and then notifications and then change the notification type from banner to an alert and you will get your custom Buttons and Title!