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

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.

Related

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
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

Trying to create Apple provisioning profile with push notifications

My apologies for any confusion or misunderstandings, this is my first phone app so I'm still getting the hang of things.
I've been getting this error when I try to enable push notifications:
no valid 'aps-environment' entitlement string found for application
And my understanding of the issue (from reading other posts and Googling) is that this is most likely due to an incorrectly setup provisioning profile.
I currently have two certificates created, one created about 6 months ago strictly for development:
FirstName LastName iOS Development Mar 22, 2017
com.namehere.tasks APNs Development iOS Sep 18, 2017
Now I've heard that you might have to remake the provisioning profile after creating the APN, however when I try to recreate it to include the APN cert, it only lists the first cert.
I do notice that my current provisioning profile says invalid, which it didn't before, if this is at all relevant:
Name and OtherName 2016 iOS Development Invalid
So my question essentially is - do I need to create a new provisioning profile now that I've created a push certificate? And why can't I add it to my provisioning profile?
do I need to create a new provisioning profile now that I've created a
push certificate?
Yes, you will need to regenerate the provisioning profile. You can think of the provisioning profile as the single source of truth for all your certificates and bundled app services (eg. Push Notification)
however when I try to recreate it to include the APN cert, it only lists the first cert.
That is correct. Just go ahead with it. The provisioning process will obtain the push cert information automatically. When you view your App ID in the developer website, you should be able to see that Push Notification is enabled.
And why can't I add it to my provisioning profile?
If you are looking for an automatic way to regenerate these provisioning profile, you could let XCode manage the provisioning for you using Team Provisioning Profile.
If you enter information about your app and assign a team to your app,
Xcode creates the necessary signing identities and provisioning
profiles for you. Specifically, Xcode creates a team provisioning
profile that allows your app to run on all your devices and use app
services.
See link for more info

Push notifications not working after switching to Enterprise distribution

I had push notifications working on an app that was using an ad hoc distribution. My client then bought an Enterprise license, and I generated new certificates/profiles, archived the app, and now we are distributing via Enterprise, but push notifications are no longer working. What steps would I have to take in order to get them working on the Enterprise version? Thanks!
Based on your description it sounds as though you did your original implementation on an AppId registered under one developer account, and then attempted to migrated the build to a second developer account.
In APNS parlance, the server that generates the push notification payload objects is called the provider and must register an APNS certificate keypair to be able to establish a secure connection between your server and the relevant Apple Push Notification gateway (Sandbox or Production). This keypair is exclusive to the AppId for which it was registered, and AppIds are exclusive to the Developer Account under which it was registered -- even with a precise matching AppId certificates registered under one account can not be transferred to a second account. If that were possible, I could look at your app's AppId, register that AppId in my own account and start sending spammy pushes to your app. Thankfully, the Bundle Seed ID is a silent element to all AppIDs and prevent that situation from occurring!
I've answered a similar question about APNS Provisioning that might help further clarify what is going on behind the scenes, so you might give Why I can't add APNs Development iOS typed certificate to provisioning profile a read.
If you want to see that your AppIDs are actually different you can use a couple of Terminal commands to export information from the original Provisioning Profile (where things were working) and from the Enterprise Provisioning Profile (where things aren't working) to see the differences:
Copy and pasting the following, taking care to update the path to your specific .mobileprovision:
/usr/libexec/PlistBuddy -c 'Print :Entitlements' /dev/stdin <<< $(security cms -D -i /path/to/your/original.mobileprovision)
Then run this command a second time updating the path to your Enterprise provisioning profile.
The output of this command will be a dictionary of key value pairs:
Dict {
get-task-allow = true
aps-environment = development
com.apple.developer.team-identifier = ABC1DEF2G3
application-identifier = XYZW1ABC2D.com.mycompany.niftyapp
keychain-access-groups = Array {
XYZW1ABC2D.*
}
}
You'll notice that the output of these two commands is different -- the application-identifier section and keychain-access-groups section will have different bundle seed IDs.
So how do I fix it?
The fix is quite simple and requires no additional development work in-app! You will, however, likely need to recompile with a new provisioning profile:
Because you've set things up already you just need to login to the Enterprise Account and enable Push Notifications in your Enterprise account's AppId
While in that AppID's configuration, you will need to generate a new SSL keypair and submit it to Apple just as you did for the original account.
Install the new certificate and private key on your Push Server
Edit your Enterprise Distribution provisioning profile, and install it in Xcode taking care to remove the old Enterprise Distribution provisioning profile.
Rebuild your application using the new Provisioning Profile.
The rebuild may be necessary because if the Enterprise AppID didn't have Push Notifications enabled, the Enterprise Distribution Provisioning Profile's Entitlements block would not contain the aps-environment key and thus be prohibited from connecting with the APNS Gateways.

iOS - Cannot use APNS certificate to create new provisioning profile

I have create a new certificate that supports push notification service with an AppID that supports push notification. Now, when I create a new provisioning profile, I cannot find this certificate (only the old normal dev certificate). What am I doing wrong?
If I understand you properly, you did everything right. It's just a different certificates.
You need to use your 'old normal dev certificate' to sign provision, then use your APNS certificate to send push to your AppID.
You don't need to create a fresh certificate, you just need to remake your existing one with push enabled and then create a new provisioning profile from that cert. Also, if you are part of a team you will need authorize the newly created cert via the team manager. Check under the Pending certs to make sure it's not listed in there or check with your team manager.

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