Push Notification after resign an iPhone application - iphone

I am wondering to know how to use command line to resign an application (with push notification) correctly.
Here are some background:
My original application works well with Push Notification.
If I resign the application via "Organizer -> Archives -> Share"
with any developer cert, Push notification still works
If I resign the application via command line codesign -f -s "iPhone Distribution: *****" -vv path/to/app, the app still works well. However, push notification stop working with message No valid 'aps-environment' entitlement string found for application 'MyPushTest': (null). Notifications will not be delivered.
Is there anybody know how to use command line do a correct resign, after which push notification will work as normal?
Thanks.

If your mobileprovisioning profile will allow push notifications - everything should run smoothly. Please note - wildcard mobileprovisioning profiles does not support push notifications.
To check if mobileprovisioning is compatible with push notifications - check "aps-environment" string presence in the profile. It should be set to "development" for Sandbox and "production" for Production gateway.
You might want to check www.aironapp.com. It does the recodesigning for you. You will need to configure Apple Dev Account in the settings.

Related

production app urban airship

I have implemented Urban airship for development successfully . I create a production app and set up the key and secret in airshipConfig file where ad hoc : YES.
I generate SSL certificate for production and uploaded to urban airship.
I want to send test notification to be sure it's work. I get device token in the audience (which is the same as I used in development) but I get error in console
"Apple Push service rejected device token XXXXXXX ". other error in console is "there is no active device " ... the status show inactive if I close the app or set the app in background.
So, Can I test the production while the app is not uploaded in app store ? what shall I do to test production?
plz , I'm totally confused
NO you can test the notification service through Development mode only.
The Production mode can only be tested once after app will be live.
If you have tested the app successfully sending the notification in Development mode than you will be able to send notification successfully in Production mode too.

Push notifications not sent to device with ad Hoc Profile (using Parse)

Push is working using my development profile and Im trying to get it working for my Ad Hoc profile.
I inspected the ad hoc profile using a text editor and found:
<key>aps-environment</key>
<string>production</string>
Therefore I have set up a production certificate set up on my app Id:
I re-generated my profile and rebuilt the project with it.
I uploaded my Ad Hoc build (to test flight) with the correct certificate (I manually checked it)
I checked the device logs and found that it did successfully register the device token:
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken
{
// Tell Parse about the device token (this gets called)
[PFPush storeDeviceToken:newDeviceToken];
...
The installation objectes appeared in Parse's web UI. (Parse is a backend service for mobile apps)
The clients pushes appears in the push log (see screenshot 3). I also created a manual text push from the web UI tool.
None of the pushes appeared on the device. I tried with both the app running in the foreground and not running at all (removed from the task bar).
Dose anyone have any suggestions? Im tired of this... I seam to have tried everything.
Seems the you defined the certificate and provisioning profile correctly. Something was missing during the process to sign the Parse connection with APNs or the certificate to send push messages to APNs.
Really sorry for my ridiculous english but this will be a bit long. Did you tried to connect to APNs by hand with your certificate and private keys?
To do that and make things more simple, put your certificate and private key in the same folder, after then open terminal and go to the same folder you put cert and key files and run this command:
openssl s_client -connect gateway.push.apple.com:2195 -cert YourCertFileHere -key YourPrivateKeyFileHere
... and type the passphrase for the key
If everything goes fine, you will connect to APNs via telnet and the connection will be not dropped, otherwise, you don't have a valid pair of files (key and cert).
Other possible reason is Parse trying to send push messages to sandbox server, I can't figure out how can you confirm this because I don't have experience with this BaaS.
I hope this can help you.

How can get device token for iphone push notifcation under Ad Hoc

The push notification is working when I use development profile , But it is not working with distribution profile. I am using the code to get the device token as follows:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(#"My token is: %#", deviceToken);
}
I am getting the same device token in production mode as in development mode. I am testing the app as Ad Hoc.
How can I get device token in Ad Hoc or production mode. Because we can NSLog device token on console for debug mode.
You can send the deviceToken to your server.
If you don't have a server, you can write the deviceToken to a file in document directory and use tools like iFunBox to see it.
you are using the developer mode of APNS, use production mode of APNS
i think you are using sandbox when creating the .pem files so remove sandbox and then try again to send pust notification.
How can production build can run on real device? Running an app built by production provisioning profile is prohibited.

Push Notification not working in Sandbox mode

In our organization we are trying to get familiar with push notifications.Our administrator generated a SSL certificate and an app id which one of my colleagues used for developing an app having push notifications which was working nicely.After that administrator disabled the certificate which stopped push notifications working.Now I am working on the same and for that purpose the certificate is enabled again.But When I used it on my machine in a sample app it didn't work.More strangely I ran the app which was on my colleague's machine and it also doesn't receive any notifications now!!!I tried to replace old certificate by the re-enabled one but that also doesn't do the job.What should I do?
If you revoke a certificate, and recreate it, you must download the new certificate because it's not the same certificate, the old has expired.

register device at run time

In the App ID section of the Program Portal, locate the App ID you wish to use with the Apple Push Notification service. Only App IDs with a specific bundle ID can be used with the APNs. You cannot use a “wild-card” application ID. You must see “Available” under the Apple Push Notification service column to register this App ID and configure a certificate for this App ID.
Click the ‘Configure’ link next to your desired App ID.
In the Configure App ID page, check the Enable Push Notification Services box and click the Configure button. Clicking this button launches the APNs Assistant, which guides you through the next series of steps that create your App ID specific Client SSL certificate.
Download the Client SSL certificate file to your download location. Navigate to that location and double-click the certificate file (which has an extension of cer) to install it in your keychain.
When you are finished, click Done in the APNS Assistant.
Double-clicking the file launches Keychain Access. Make sure you install the certificate in your login keychain on the computer you are using for provider development. The APNs SSL certificate should be installed on your notification server.
When you finish these steps you are returned to the Configure App ID page of the iPhone Dev Center portal. The certificate should be badged with a green circle and the label “Enabled”.
To complete the APNs set-up process, you will need to create a new provisioning profile containing your APNs-enabled App ID.
IS it posssible to do theses steps through code.
No, this completes only the certificate part. you need to implement code in your app and also you need a server(SSL supported).what you have to do after generating certificate is register your device for remote notification.you'll find that how to do this in Remote notification guide.then you'll get device token send the device token to your server and your server will forward the device token+message(you want to show on device) to APNS.APNS will send the notification to the device.also you need to show certificate when sending device token from your server to APNs.read the whole Remote Notifications Guide carefully.