pushsharp push notification to iOS error with the certificate - ios

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
The error happens at the following location
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
App ID's
Certificates
Provisioning profiles
Xamarin visual studio has no provisioning profile as expected
Starting with a Clean slate
Key Chain access
Request certificate from certification authority (Code Signing)
save the cert signing request
Registered a new app with bundle identifier and push services enabled
Add new provisioning profile
create certificate
Use the certificate signing request created (Step 3)
download certificate
Double click on the certificate to install into keychain
(Keychain has new entry now)
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)
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
Key Chain access
Request certificate from certification authority (APNs)
Save the cert signing request
Select the app id created (Step 4)
Edit App ID
Under push notification select create certificate
Select the certification signing request(Step 14)
Download the certificate
Double click on the certificate to install it
(Now two entries show in Keychain certificates, one for code signing and another for APNs)
Select the APNs certificate in keychain access and export .p12 file
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!!!

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

Related

What is a right way to generate the Certificates while using FCM

I am amazed to see that When ever I am creating Certificates "Apple Push Notification service SSL (Production & Development)" it is not shown in Profiles
Things are very much changed on Developer portal And after bashing my head many times (deleting and creating different certificates) its is not working for me
What I am doing:
Attempt 1: When I create certificates from certificate menu it did appear on Profile menu (from where we create provisioning profile & selects certificates) but when I create APNs SSL certificate it never appears in provisioning profile menu
Attempt 2: I created separate SSL certificate and created p12 file from them and uploaded them into FCM server and then i created normal certificate and generated Provisioning profile and installing them in xcode it gives me error of not including something for Notification.
So after trying all these I am now not able to run app on device and not able to work around for FCM notification
Question: What steps are needed to create certificate while working on FCM?
"NOTE: Since all interface and working procedures are updated on developer portal is updated so all help on SO and other places are out date. Please let me know what should I do and how it is done in precise manner it will be great help. THANKS"
I suggest to use for push notification, .p8 key because this same key will work for both sandbox And production mode.
Use this solution to generate .p8 Key And upload key on firebase read this articles

How can I "revoke and request" my iOS Developer Profile?

I am trying to export an .ipa file from XCode 6, and I get an error like this:
The dialog says "revoke the current certificate and request one again", but I don't see a way to do that. The Apple Troubleshooting page for this issue suggests I should click the "Revoke and Request" button, but I don't see one.
How do I revoke the old developer certificate and request a new one?
I suppose that the certificate is a distribution one, not development one. It seems that you have installed your iOS Distribution certificate in another Mac. And, it seems again that you download this certificate from Apple portail and import to your new machine. Of course, the simple import is not valid. Cause a certificate requires a private key to be associated with.
Then, you have 2 solutions:
Export your certificate from old machine (include private key) then import to your new machine. I recommend it.
Revoke this certificate if you do not use anymore on old machine. Then, from new machine, create new request signning and request again the distribution certificate.
Visite your account, in distribution certificate section, click to the certificate to revoke, you will see "Revoke" button.
Beware that all provisioning profiles created with this certificate will be invalidated.
Just for info, you have only <= 2 distribution certificates to be created.

Cannot find app private key for iOS app

I need a private key (.p12 file) for my iOS app in order to enable push notifications through Amazon SNS. I can't find a private key for my app in Keychain Access. I only see Developer and Distribution Keys for myself and my company. I could have deleted it as I deleted two things related to the app from Keychain Access in order to use updated versions. I may have deleted the wrong thing. Can I regenerate the keys in Xcode? If not, how do I create a new app to get new keys?
UPDATE: I found this tutorial that describes in detail what I am trying to do.
http://www.adventuresofanentrepreneur.net/creating-a-mobile-appsgames-company/setting-up-aws-sns-to-send-push-notifications-to-ios-devices
Steps 4.1-4.5 are the steps I cannot perform. This is because there is no key for my app in my keychain only certificates. I tried creating a wholly new app and following the process again and I have no key for that app either.
UPDATE 2: I found the following instructions that make me think there is something wrong with my Mac as it doesn't generate a key when I install the APNs certificate I download from Developer Center.
http://kklolk.blogspot.co.uk/2013/11/amazon-sns-with-apple-apn.html
If I download the APN certificate and install it on my keychain, I see the certificate on the keychain but not the key. I have keys on my keychain for non-APN developer and distribution but these fail the openssl test against the Apple push servers listed in the tutorial
CONNECTED(00000003)
depth=1 C = US, O = "Entrust, Inc.", OU = www.entrust.net/rpa is incorporated by reference, OU = "(c) 2009 Entrust, Inc.", CN = Entrust Certification Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0
140735234900832:error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown:s3_pkt.c:1256:SSL alert number 46
140735234900832:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177:
---
I can use my non-APN .p12 files in the Amazon SNS New App page on AWS but they give the error - The credentials you entered are invalid. Please enter valid credentials and try again. I also tried combing the APNs certificate generated for the app with the keys from the developer and distributor keys, which gave the error - There was a transient failure registering the app with Amazon SNS. Please try again (Request ID: Unknown).
The problem certainly looks to be that my computer is not correctly generating keys from the certificates for APNs Development and Production.
I found an answer here:
Can't find private key for Apple Development Push Services
For me, I already had the certificate, but I didn't know how to find its private key. If you click "My Certificates" under categories, then a dropdown arrow appears next to your certificate. Click this and you should get your private key.
I had the same issue myself. What I found was that you need to make sure that the certificate that you are using to generate the .p12 file from in keychain access is one you created using your CertificateSigningRequest file.
I went back to the Apple Developer Member Center and created another Certificate for development purposes using my CertificateSigningRequest file. When I downloaded this and opened it up in keychain access the private key was now included. Exporting that private key pair as .p12 file allowed me to successfully register the application in AWS SNS. Note if using a Development certificate to export your private key you will need to create your application in SNS using the APNS Sandbox selection. If you are using a Production Certificate you need to use the normal APNS selection.
I have a tentative answer for this. When creating a certificate in Keychain Access, first select an iOS Developer or iOS Distribution, then go to the menu Keychain Access > Certificate Assistant > Request a Certificate from Certificate Autority With "iOS D...".
The above is during step 1 of http://docs.aws.amazon.com/sns/latest/dg/mobile-push-apns.html#verify-cert-private-key-apns
Before I was simply going straight to the menu where I noticed it then said Request a Certificate from Certificate Authority With "". Selecting an iOS developer key first results in their being a key associated with the certificate cer when imported. This let me generate the p12, which AWS accepted. However, messaging to iOS devices still isn't working so it isn't a full success yet.

Push certificate not appearing when creating a profile in iOS dev portal

I've created a dev push certificate for my app (following these steps http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1)
and I can see the certificate appearing in the certificates section of the portal.
Now I'm trying to create a provisioning profile which includes the certificate, however when the portal asks which certificate(s) to include in the profile the one I just created is not listed.
I have triple-checked that the app id I used to create the certificate is the same as the app id I am using to create the profile - and if I examine the app id the green dot has appeared next to the push enabled section.
So why is the certificate not appearing as an option when creating the profile?
Provisioning profile certificates are separate from push notification certificates. You probably need to generate a developer certificate instead.
Push certificate is just an SSL certificate for your web server or 3rd party service. Nothing to do with provisioning. Just be sure to have the same bundle ID.

Can`t find Certificate Signing Request (CSR) for Apple Push Notification service

I`m trying to add to my app Push Notification service. I have already successfully distributed my app via Enterprise Distribution, by following all instructions. But now enabling Apple Push Notification service i need Certificate Signing Request (CSR) file and accidentally deleted him. How can i get another CSR file without creating new certificate and going through the hard process of app distribution?
Like it tells you in the provisioning portal - open keychain access --> app menu--> certificate assistant --> request a certificate from a certificate authority.
However, you may have to re-sign your app with the new certificate that is eventually generated. The CSR is the "easy" bit!

Resources