4

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?

jdehlin
  • 8,485
  • 3
  • 18
  • 33

1 Answers1

5

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.

Dmitry Khryukin
  • 6,281
  • 7
  • 34
  • 57
  • It was number 2. The documentation says the parameters are (this AppleNotification n, string key, params object[] values). I realize now that the params keyword lets you specify a method parameter that takes a variable number of arguments. – jdehlin Jun 03 '13 at 23:47