Push notifications don't work if app is installed via iTunes but they do if installed by XCode - ios

I have an app that uses push notifications and I am trying to distribute it to testers for testing.
If I create an ad-hoc distribution which gets installed via iTunes then everything works except for the push notifications, which never arrive.
But if the app is installed using XCode then the push notifications do arrive.
When I build for installation using XCode I set the code signing identity within XCode to my development profile. When I build for ad-hoc distribution I set the code signing identity within XCode to be the ad-hoc distribution profile when building the archive, then sign the archive for distribution again with the ad-hoc profile (I found this was the only combination that would allow installation via iTunes without an error message).
All the devices have been added to the ad-hoc distribution profile and to the apple push profile (and also to the team provisioning profile), the profiles have been renewed and refreshed within XCode.
Even with my own iPhone I can get push notifications to work if I install with XCode but not with iTunes.
Am I signing the ad-hoc distribution with the incorrect profiles, if so what is the correct combination of profiles?
Is there another reason why the push notifications don't work for the ad-hoc distribution but do when the app is installed via XCode?
These are the profiles used:
1) Apple push profile which has an App id of abcdef.com.company.mno
2) Project Development profile which has an App id of abcdef.com.company.mno
3) iOS Team provisioning profile which has an app id of abcdef.*
4) AdHoc Distribution profile which has an app id of abcdef.com.company.mno
5) My developer profile which has an app id of abcdef.com.company.mno
** since first posting this I tried creating a new iOS Team provisioning profile using the abcdef.com.company.mno app id but it made no difference **
The abcdef.com.company.mno App Id is showing Push Notifications for Development as being enabled (which is correct, we are not yet using Production pushes). Also its Development Push SSL Certificate is showing as enabled.
The code signing identities are: first pic what I use for installing/running using XCode, 2nd picture when building an archive for ad hoc distribution.
The description for the iPhone Distribution profile in XCode says: "Ad Hoc distribution profile (for bundle identifiers com.company.mno)".

This morning I had a similar issue trying to compile an In House app (I think it's the same issue). I had the iPhone plugged to the computer and I saw in console one warning like: entitlement 'aps-environment' has value not permitted by a provisioning profile
I tried this solution, but I had no success:
'aps-environment' has value not permitted by a provisioning profile
So, my app was working correctly in release mode running from Xcode, but when I tried to export with Ad Hoc certificate my iPhone shown that message on console.
Finally I went to profiles in iPhone and deleted all. I went to profiles in Organizer and deleted all too. I edited the provisioning profile via Provisioning portal and downloaded them again.
I changed code signing to Don't code sign. Changed again to In House provisioning profile, exported to a file and everything worked fine!

You're probably signing the adhoc version with a wildcard app id provisioning profile. Make sure the Code Signing Identity in the build settings is explicitly using your explicit-app-id provisioning profile.

Related

Xcode Signing Failed to create provisioning profile

I subscribed to the App Developer program. I paid the fee. I've done Certificates, Identifiers & Profiles. I added the app to App Store Connect.
xcode signing
I am getting the errors above. I don't have an iPhone phone. I'm developing on my macbook computer.
xcode device
How can I resolve this error?
As I can see in image that "Automatically Manage Signing" is enabled for this Xcode project. So Xcode is trying to create the provisioning profile for you but not able to create it.
B'coz you need to add account in Xcode from Xcode -> Preferences -> Account -> Click on + icon at bottom to add a new developer account.
You need to create provisioning profiles.
Once you have created provisioning profile, download it and install on your machine.
Please make sure the certificate used in cretation of the provisioning profile must be in your machine's keychain.
If those certificates not installed in your keychiain then you will see certificate issue in Xcode.
But I would recommend to create provisioning profile manually from apple developer portal as you can see and mainly you can know that which certificate and devices are used in the profile.
You can create following provisioning profiles for your app.
Development Profile
You will be able to run/debug app on real device.
The device must be added into the profile.
This can be used for only development purpose.
Adhoc Profile
You will be able to install app on real device but not able to debug it.
The device must be added in profile to install app on it.
It acts as a release build but not a actually release build.
Generally develop send the adhoc build to client for testing of app.
App Store Profile
You will not able to run app on device using this profile.
It will be used to upload app on App Store or create the release build for distribution on App Store.

iOS Native Application - Requires a provisioning profile with the Push Notifications feature

I am supporting for one existing native iOS application. For this am able to generate IPA successfully from Xcode but while generating build from devops am facing the issue:
Requires a provisioning profile with the Push Notifications feature
How can I get past this error and build for my device?
A Provisioning Profile must be installed on each device your application code should run on. Each Development Provisioning Profile will contain a set of iPhone Development Certificates, Unique Device Identifiers and an App ID.
Devices specified in the Development Provisioning Profile can be used for testing only by those individuals whose Development Certificates are included in the profile. To create :
Login to the developer account connected to your project, and under Certificates, Identifiers & Profiles -> Profiles -> Register a New Provisioning Profile by clicking the add new button.
Choose for which purpose provisional profile is required.
a. For developement purpose. (the app can be downloaded only in registered devices if the application is in development stage. For this, The device UDID is required to be added in device list).
b. For distribution purpose ( The provisonal file required for uploading app in the app store)
After Selecting above, click continue.
Choose your Appid (i.e. Bundle id) from the list and click continue.
After registering, download the provisional profile (File with extension name.mobileprovision will get downloaded) and double click the file to the Xcode project to include the provisional certificate to be added.
you need to follow below steps
go to developer account
make provisioning profile for bundle identifier that you are using
Adhoc(test) or Distribution(production)
enable push notification
download the certificate
click on the certificate

APN & TestFlight : Xcode chooses a wrong (XC*) provisioning profile to submit archive

I am using Parse.com to send client push notifications, from one iDevice to another.
It works well with the 'development' setup, i.e. with
- the Push Notification Setting of the appID set on 'Development'
- a development SSL certificate
- a development provisioning profile
With this setup, I managed to send a push notification to myself (sender = receiver = my device).
Now I want to test the communication between 2 different devices. To do so, I use TestFlight (because this is the way I usually send updates to my client).
I followed all the recommended steps to move from Development to Ad Hoc :
updated AppID settings to 'Production' Push Notifications
created a production SSL certificate, uploaded it to Parse Server
generated a new Provisioning Profile set for Ad Hoc Development, and installed it on the iPhone (checked on Organizer Library). This Ad Hoc Provisioning Profile is named : 'PushMyMoving_Push_Production_Profile'
updated the Project/Target build settings under 'Code Signing' to tell Xcode that it should use PushMyMoving_Push_Production_Profile (and the corresponding iPhone Distribution Certificate) for now on.
The issue : the build is successfully submitted, but as soon as it is, Apple sends me this e-mail :
And, naturally, I can no longer receive/send push notifications. Here's what I tried so far :
I opened the PushMyMoving_Push_Production_Profile to see if the Push Notification Entitlement was missing. It isn't. So my guess is that Xcode doesn't submit/archive the build with the right Provisioning Profile, although I'm telling it to do so in the Build Settings!
Actually, I noticed that whenever I submit the build, Xcode automatically selects a wildcard provisioning profile :
I tried to delete all the wildcard provisioning profile from Member Center & my Mac, but (annoyingly!) Xcode automatically re-creates them whenever I refresh the Provisioning Profiles Panel under Xcode>Preferences>Accounts. Is there a way to completely erase wildcard profiles ?
This thread : XCode 6 and Ad-Hoc distribution without XC: provisioning suggests that it can be that the "ad-hoc profile doesn't contain all of the devices on your team" but I carefully checked ALL the devices I have when I generated the Ad Hoc profile.
I've also tried to edit & re-generate, re-install the provisioning profile (a common advice apparently) but Xcode still does it its way.
Any help would be much appreciated! I have been struggling for days, it is really frustrating when the problem does not come from the code !
Thanks
Thanks Rhythmic Fistman for the help. I found the answer today : I was submitting my build to TestFlight with an Ad-Hoc provisioning profile, instead of an AppStore Distribution Provisioning Profile. I had read somewhere that Xcode was creating a Ad-Hoc provisioning profile behind the scenes while submitting to TestFlight, so I thought that the Ad-Hoc profile was appropriate. But since TestFlight runs like the AppStore, not having registered the subscribed devices UDID in advance (as with Ad-Hoc distribution) it makes sense to use a "broader" profile such as an AppStore Distribution Provisioning Profile.
So for anyone using Push Notifications with Testflight, you do need an AppStore Distribution Provisioning Profile. Then Xcode will automatically picks it for the submission phase.
Expunging wildcard provisioning profiles from Xcode and the developer portal can be done, but you can probably fix your problems by explicitly setting your Release Provisioning Profile to the correct Ad Hoc profile in your build settings:
This should stop Xcode getting too creative when Archiving.

iOS: Is a Distribution build supposed to work on my Developer device?

I am confused with profiles and certificates for the build I am trying to put on the Appstore.
In developer.apple.com/ I have properly created both a developer and distribution certificate. they are both linked to the single app I have created.
I have registered my device (iphone)
I also have properly created 1 development provisioning profile and 1 distribution provisioning profile.
When I build with dev certificate + dev provisioning profile: app works fine on my device
But I know the build needs a distribution certif and provisioning profile in order to get approved on the appstore.
However when I build with distribution certificate + distribution provisioning profile, the build is succesful, but I can't launch the app on my iphone, other iphone (with http://www.diawi.com/ or iTunes). It immediately crashes with the infamous error popup: "unable to download. "XXX" could not be installed at this time".
When I look at the device's log from Xcode, it clearly states the crash comes from a profile issue.
Is the distribution build supposed to work on my iPhone?
You can check you Beta release build to your developer device using 'Apple Ad Hoc Distribution profile/certificat'. Here are Apple Dev link Beta Testing Your iOS App
No. A distribution build will not just be installable on your device. You are meant to submit it to iTunes Connect from Xcode, where you build it from an archive, or from Application Launcher where you would submit it as an IPA.
you should have created adhoc distributed provisioning profile and add your device to that profile.
But you need iTunes Connect to submit the app to App Store. This time you can create provisioning profile for app store.
Advantages of iTunesConnect.
1. You need not to add new device to the provisioning profile every
time you want to test the app in new device.
2. You can add as many as new test users to the app and can mark them as internal and external users.
3. You can upload as many builds as you want and test those builds.

Initializing my new AD-HOC profile for testing Push Notifications on Production

I want to test Push Notifications in iOS production version before I publish it. I understand I cant sign it with distribution profile ,only AD-HOC profiles.
So I created an AD-HOC profile, selected the right bundle, selected my device that I work with and created a new profile. I downloaded it and after that I select it in:
Provisioning Profile -> Release - AD-HOC-NEW
Provisioning Profile -> Debug (Any SDK, Any iOS SDK) are with Automatic.
It compiles and installed on my device through Xcode but notification don't come.
When I try to change Debug settings also to my new profile I'm getting an error :
"No provisioning profiles with a valid signing identify(i.e certificate and private key pair) were found.
No codesigning identities (i.e certificate and private key pairs) that much the provision profile specified in your build settings ("AD-HOC-New") were found. Xcode can resolve this issue by downloading a new provisioning profile from the member center."
I press "Fix Issue" but It dont fix it...
What could be the problem?
I think you should install your binary not straight xCode but as a real over-the-air/ ad hoc deployement.
The consequence is that your application will request at launch not a token from the sandbox environment but from the production one, and this will match your certificate (which is a production one too).
You do a real ad-hoc deployement both by installing your .ipa through iTunes, or by using a solution such as Testfligt.

Resources