1
votes

I am currently working on automatic updates for Passbook (wallet) tickets and am experiencing some trouble using the Pushsharp library by Redth.

I am using a Push notification certificate from the apple developer portal.

I have tried to export my certificate as .p12, .pem and tried to use only the private key as .12 or .pem but nothing works. This is my full certificate (information is blanked out for security reasons): https://cdn.pbrd.co/images/HUJtb7b.png I dont have enough reputation to post images so a link is all i can provide.

            var succeeded = 0;
            var failed = 0;
            var attempted = 0;
            var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, ConfigManager.CertPath + "PushCertificateV2.p12", ConfigManager.lvppass, false);

            var broker = new ApnsServiceBroker(config);
            broker.OnNotificationFailed += (notification, exception) =>
            {
                failed++;
            };
            broker.OnNotificationSucceeded += (notification) =>
            {
                succeeded++;
            };
            broker.Start();
            attempted++;
            broker.QueueNotification(new ApnsNotification
            {
                DeviceToken = pushtoken,
                Payload = JObject.Parse("{ \"aps\" : { \"alert\" : \"Test notification\" } }")
            });
            broker.Stop();

The purpose is to send a push notification to the APNS and receive an answer, sadly i am only receiving the error: Apns notification error: 'InvalidToken'. If it means my Pushtoken from the device is incorrect it would be weird because i am using the pushtoken i recieved from the iPhone and checked it multiple times to be sure. I have tried searching for solutions on the web but have not found a working one so far, so any help would be greatly appreciated.

Thank you in advance.

1

1 Answers

1
votes

Okay, for anyone having the same issues in the future, it turned out i needed to use the same certificate i use for signing the passes and updating them. And that you cannot use the sandbox APNS because all passbook tokens are production tokens.