Search code examples
c#iospush-notificationpempushsharp

Register Apple Service using a .pem certificate


I would like to send a test PUSH message to an iOS device. I am provided with the device token and one .pem file as certificate. But I cannot seem to find a way to create a new ApplePushChannelSettings object using this .pem file. The examples on the web all use a .p12 file that come with a password.

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

//Registering the Apple Service and sending an iOS Notification
var appleCert = File.ReadAllBytes("ApnsSandboxCert.p12"));
push.RegisterAppleService(new ApplePushChannelSettings(appleCert, "pwd"));
push.QueueNotification(new AppleNotification()
                           .ForDeviceToken("DEVICE TOKEN HERE")
                           .WithAlert("Hello World!")
                           .WithBadge(7)
                           .WithSound("sound.caf"));

Should I ask for a .p12 certificate for the target app or is there a way to use a .pem file with PushSharp?


Solution

  • From my experience, all Push notifications services ask for a .p12 certificate. You should try that.

    EDIT:
    After a quick search, I think that you don't have a choice. .p12 it is.