I have successfully implemented APN for development Environment. But i am facing problems while implementing the same for ad-hoc distribution environment.
Can anybody please suggest me do i need to create different App Id , Certificate and Provisioning Profile for that?
And is there any change in Sandbox?
A tutorial of steps will be very much appriciated.
Thanks
Saleel Karkhanis
For Adhoc distribution, Please follow the instructions below:
- In Provisioning Portal, Create a Distribution certificate.
- Get the "Device ID" of the iPhone that you intend to use for testing. Open iTunes -> Connect your device -> Select your device -> In Summary Pane, Click on Serial Number label, it will change to identifier (40 Hex characters) -> Choose Edit, Copy.
- In Provisioning portal, Go to Devices -> Add new Device -> Enter the copied Device ID and give it a name.
- In Provisioning portal, Create a Distribution Provisioning Profile. (Go to Provisioning -> Distribution). For Distibution type , Check "AdHoc". Select the App Id, If you have a distribution certificate, it will automatically be selected here. Select the newly entered device and Submit. Download this Provisioning Profile.
- In Xcode, Window -> Organiser. Click on Devices and select Library -> Provisioning Profiles. If you are the admin, then Clicking on Refresh should fetch the newly created provisioning profile. If not, Drag and Drop the Adhoc Provisioning Profile to this list.
- In Xcode, in your project Build Settings -> Code Signing Identity -> Release section, Select "iPhone Distribution". For "Any iOS SDK", Select the newly created Provisioning Profile. It will be available in the list.
- In Xcode, Product -> Archive. Once it finishes, Archiving, it will open the Archive window automatically. Select the project and click Distribute, In the Distribute window, Select "Save for Enterprise or AdHoc Deployment" -> Select the "Code Signing Identity" which corresponds to the new Provisioning Profile. Continue the process and this will create an ".ipa" file.
- Send this .ipa file and the new provisioning profile for testing adHoc distribution.
How to load the adHoc distribution on the test device:
- Open iTunes, Connect your test device.
- Drag and Drop the new provisioning profile to iTunes.
- Drag and Drop the .ipa file iTunes.
- Sync ur device. This would load the app.
For Push Notifications to work on Adhoc distribution:
- Use the production certificates.
- Use production APN Host: gateway.push.apple.com
- Use production APN Feedback Host: feedback.push.apple.com.
I had major problems with this as well. I had absolutely no errors in my code. I just never got a push notification on the phone in Ad Hoc.
It turns out that I had some sort of problem with my certificates. I created
I'm not really certain what the problem was, exactly, but I solved it by logging into my developer account as the team agent and recreating everything under that login. I had originally created the certificates as a team admin.
Your development mode may work just fine, since any team member can create development distribution profiles. But only certain team members can create distribution profiles. Have your team agent create everything and try it again.
There is a separate persistent connection to the push service for each environment (Development and Production). The operating system establishes a persistent connection to the sandbox environment for development builds; ad hoc and distribution builds connect to the production environment.
If you are using GCM. Go to your AppDelegate.swift. Find method: didRegisterForRemoteNotificationsWithDeviceToken and replace
registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:true]
with
registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption:false
In addition to Sushma Satish's answer ,
When you change certificates from developement to distributon , the device token generated for your phone is different.
So make sure you're changing the device token on the server.