Abe
Abe

Reputation: 1929

pushsharp push notification to iOS error with the certificate

Hi all I am new to iOS development, I have put in the deep end to get push notifications. I found pushsharp and was using this tutorial

Tutorial I a using

I have used a windows application instead of web application and add the latest pushsharp. The code build and runs but i get the following exception

Exception

The error happens at the following location Error location in code

I have revoked my certificate and recreated it several times and also i have tried exporting the certificate and the key. Both give me the same error.

When I am creating the certificate, I created one for iOS Development in Apple portal.

This is what I have tried so far Based on comment from Jack Hua, i have tried the following

Logged into apple portal and deleted

Xamarin visual studio has no provisioning profile as expected

Starting with a Clean slate

  1. Key Chain access
  2. Request certificate from certification authority (Code Signing)
  3. save the cert signing request
  4. Registered a new app with bundle identifier and push services enabled
  5. Add new provisioning profile
  6. create certificate
  7. Use the certificate signing request created (Step 3)
  8. download certificate
  9. Double click on the certificate to install into keychain (Keychain has new entry now)
  10. Right click an export a p12 (If I do not do this I wasn't able to see the certificate in the provisioning profiles section)
  11. Select the certificate and create the provisioning profile Re-open Xamarin studio and the provisioning profile is shown in the project properties

Now create the APNs develpment certificate

  1. Key Chain access
  2. Request certificate from certification authority (APNs)
  3. Save the cert signing request
  4. Select the app id created (Step 4)
  5. Edit App ID
  6. Under push notification select create certificate
  7. Select the certification signing request(Step 14)
  8. Download the certificate
  9. Double click on the certificate to install it (Now two entries show in Keychain certificates, one for code signing and another for APNs)
  10. Select the APNs certificate in keychain access and export .p12 file
  11. Include this in my sample project (Create as per the youtube video with appropriate device token)

I still get the same Apns connection error.

What am i missing?

Based on Jack Hua comment I have further made this attempt. I have set the validation flag to false, I still get the connection error however the inner exception is 'Invalid Device Token'

Made a bit of progress after some research, the device token i had has spaces removing the spaces i do not get any errors however the notification is never shown on my iPad. I am using Sandbox and iOS development certificates, provisioning profiles. Wondering is this a know issue in development and it will work in production. Any help is greatly appreciated guys!!!

Upvotes: 0

Views: 595

Answers (1)

nevermore
nevermore

Reputation: 15816

That error message is generated when creating an ApnsConfiguration object, see source code.

 if (!Regex.IsMatch (commonName, "Apple.*?Push Services")
                    && !commonName.Contains ("Website Push ID:"))
                    throw new ArgumentOutOfRangeException ("Your Certificate is not a valid certificate for connecting to Apple's APNS servers");

You are not creating a push certification... The tutorial you are following is creating a distribution provisioning profile that allows you to submit your app to the Apple App Store (not notification).

You can follow this document to generate a notification certification and config your app to enable the ability of push notofication.

Refer: send-push-notification-to-ios-pushsharp-certificate

Upvotes: 1

Related Questions