Question

I have Android and Apple push notifications working with PushSharp, but I'm having trouble sending custom data with the Apple notifications.

This sends perfectly:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithBadge(7));

This doesn't work at all:

push.QueueNotification(new AppleNotification()
                                   .ForDeviceToken(device.Identifier)
                                   .WithAlert(message)
                                   .WithSound("default")
                                   .WithCustomItem("incidentId", new[] { 1 })
                                   .WithBadge(7));

The latter never hits NotificationSent, NotificationFailed, ServiceException, etc. and never makes it to the phones.

Using PushSharp version 2.0.4.0

Am I doing something wrong with how I'm trying to add the custom data?

Was it helpful?

Solution

1) did you set up production environment (not sandbox) in your ApplePushChannelSettings?

//Create our push services broker
var push = new PushBroker();

//Registering the Apple Service and sending an iOS Notification
var appleCert = File.ReadAllBytes("YourCert.p12"));

//isProduction - development or ad-hoc/release certificate
push.RegisterAppleService(new ApplePushChannelSettings(isProduction, appleCert, "pwd"));

2) try to use

WithCustomItem("incidentId", "1");

3) maybe the reason is the wrong sound file name. I see that it doesn't have an extension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top