Recieving notifications from APNs in iPhone applicationg without provisioning profile - iphone

Task:
have a jailbroken iPhone
need to write an application which would receive notifications from APNs
Problem: after running the application on iPhone program shows an error: "no valid apps-environment entitlement string found for application" (at registerForRemoteNotificationTypes- call i suppose).
As I've understood the problem source is that I built the application without a provisioning profile.
Question: is there any possibility to make the program work before I receive my apple developer account (in order to create a provisioning profile)?

Apple Push Notification Service requires that a device be registered with the service in order to receive notifications. In order to register with the APNS server, an app needs to be signed and provisioned.
Also, jailbroken phones may not work correctly in many cases where a legitimate application, that has been signed, provisioned and distributed officially via the iTunes App Store, is being used.
I believe it was reported that notifications from the AIM app intended for legitimate iPhone users were being sent to people with jailbroken iPhones, who in some cases didn't even have AIM installed. This probably has something to do with the fact that jailbreaking allows a user to change their device's UDID, which just screws everything up.

No. You need to have a valid provisioning profile.

You can send a fake push notification locally if you installed MobileSubstrate, with this method:
http://networkpx.blogspot.com/2009/06/sending-push-notification-locally.html

Related

Can I use APNS on iOS Developer Enterprise Program without using MDM

I have actual experience on the normal iOS Developer Program, But I have NEVER experienced using an Enterprise Program. Enterprise account has some differences with the normal one like it has NO itunes connect(so no storekit, game center) but it has no limit on UDIDs.
Looking at this post iOS Enterprise developer Account: get device token , it seems that the so called MDM uses APNS but it will have a slightly different implementation/requirements.
I don't want to use MDM, but I want to implement APNS similar to a normal developer account. Can I do APNS without using MDM on an enterprise account? Will implementing APNS be the same with using a NON Enterprise developer account. Or is it required for me to use the "MDM"
Sorry for the newbie question and thanks in advance for all the help.
Will implementing APNS be the same with using a NON Enterprise
developer account. Or is it required for me to use the "MDM"
Yes, you can use push notifications in enterprise apps just as you can with apps distributed through the App Store. No, you don't need to use MDM in order to do it. MDM uses APNS, but APNS doesn't rely on MDM.
To use APNS, you'll need to create an app ID that's specific to a single app -- you can't use a wildcard app ID.

Grant access to server only with validated IOS devices through Unique Identifier

I have 10 IOS devices in my company predominantly ipads running IOS 6. I have a server where I've created the appropriate web services for my devices to communicate with. I wish to extend the current setup by only allowing validated devices access to the webservices.
I have looked into passing the UDID as an extra attribute to the web server which would then be run against a database containing encrypted UDIDs and if its found a match then the device is validated and allow the web service process to continue.
However i understand that UDID is now depreciated. What is the easiest way i can implement a unique UDID for each device which would also work for future in-house application updates?
Why don't you create a standard login system whereby the user logs in on the device with a username and password, and then the server returns a certificate that can be used to validate future interactions? Why restrict users to specific devices when you can just require a login. The end result - limiting which users can use the system - is still realized, but in a more flexible and extensible way.
Use the UIDevice identifierForVendor to identify the device under iOS6.
[[UIDevice currentDevice] identifierForVendor]
From Apple docs:
"The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps onthe same device that come from different vendors, and for apps on different devices regardles of vendor."
Another way I have used is to generate a UUID on the server, email it to the user with a URL scheme that opens the app and the app saves it in the keychain. The keychain saves the UUID across app delete/reinstall.
Use the MAC address of the device. It is not against Apple Policy and it NEVER changes.

How do I check if an iOS distribution provisioning profile has push notifications enabled?

I have an app which was supposed to have push notifications enabled, but for some reason doesn't have them. I've seen other people download and install the app, and it doesn't even prompt them for permission to send push notifications. As expected, this app doesn't appear in their Settings > Notifications.
However, on my iPad, I am able to receive push notifications from this app, and it does show up on my Settings > Notifications. I have deleted and reinstalled the app to make sure I had the same thing everyone else has (and not a development version), and I'm still able to get notifications.
Now, this app was written for a client who sent me all the provisioning profiles (dev, adhoc, distribution) as well as the files needed to be able to send push notifications, so I can't know for sure that everything was properly created.
My theory right now is that:
the adhoc profile I received was "properly created" (i.e. generated after setting up APNs on the app's App ID in the Provisioning Portal)
the distribution profile I received was generated before setting up APNs for this app (and thus, it's not "push enabled")
the reason I'm able to receive push notifications on my device is because during development I installed an adhoc version, which prompted me for permissions to receive push notifications, and even though I've deleted this adhoc version and downloaded the version from the store, the device has "cached" the fact that I'm willing to receive notifications and no longer prompts me for it. I've checked with other apps and indeed, after I delete and reinstall them, they won't prompt me again for permissions to receive push notifications.
So my questions are:
Does this theory make sense?
If it does, this means I'll have to ask the client to generate a new distribution provisioning profile. How can I verify that this profile is "push enabled"? (i.e. considering that I can't just install an app compiled with it)
Ok, I may have found a way to verify whether or not the profiles have push enabled.
If I open the .mobileprovision file as a text file, there is a bit of XML there (a plist apparently) which I'm guessing for a distribution profile should have this:
<key>aps-environment</key>
<string>production</string>
And indeed, the adhoc profile had this and the distribution profile didn't, so... I'm guessing this was the problem.
Still, any feedback would be helpful :)
Slightly different, but still useful: when you upload an app to iTunes connect, you can check whether it has Push notifications (or any other entitlements) enabled.
To do this, go to Manage your Applications, select the application, then go to "View Details" for the version you want to check.
From there, go to the "Binary details" page - there's an Entitlements field that shows what the entitlements the binary has. If Push Notifications are enabled, you'll see a "aps-environment: production" line in there.
Make sure that the distribution provisioning profile is generated after creating aps_certificate. High changes the profile may miss out aps-environment
I added the following to AppDelegate.m so I could see exactly what settings were enabled in debug
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
NSLog(#"Receiving Notification Types: %lu", (long)enabledTypes); //0=none 1=badge 2=sound 4=alert 8=NewsStandContantAvailability
I got this from a Very inclusive and useful link: Apple Push Notification Service Tutorial - Part 1
it was extremely helpful for me.

Push notifications work for Ad Hoc, but not when downloaded from the Apple store

My app just got approved for the apple store. I downloaded it an installed it on my iPhone - but it looks like push notifications are broken!
I was successfully testing push notifications in production using an adHoc provisioning profile. I had no problems. The only thing I did differently when I submitted to apple was using an app store distribution profile.
The application never asks me (or anyone else who has downloaded it) if I want to receive push notifications. Consequently, the phone never talks to my server to send the push token (because application:didRegisterForRemoteNotificationsWithDeviceToken: is presumably never called). Also the application does not appear in the settings app under the notification settings.
What could I be doing wrong??
EDIT: While the app was awaiting approval, I was having some trouble generating my production push certificate. Could this be relevant?
Problem generating APN SSL certificate after submitting to apple store
Be sure you've created your production App ID and have enable push notifications upon it. Then create the provisioning profile for that app. Download and open the file with a text editor to MUST make sure that the profile contains this key and value:
aps-environment
production
If not, then make sure you really have enabled the app ID for production push before you generated your provisioning profile.
After you make your build, you can check the final build to verify it has the aps-environment entitlement (you're looking for the aps-environment code signing entitlement under "Internal requirements):
codesign -dvvvv --entitlements - MyCoolApp.app
Did you use the same Application ID for both the ad-hoc and the distribution mobileprovision files? It needs to be a complete identifier, rather than just partial.

Are push notification tokens unique across all apps for a single device?

I will have multiple applications on the app store and 1 urban airship account to send push notifications to all of these devices. What I want to know is if each Apple device has the same "push token" across all applications? This is more of a database architecture thing so that I don't duplicate a push token many times if one single device uses many of my apps.
If each Apple device generates a unique push token for each application it has installed my architecture needs to change.
Device tokens are not exactly unique per device; they're unique per operating system installation. So if a user buys a new device but does not restore from backup, then they'll get a new device token. And if a device is wiped, it will get a new device token, so the new user doesn't get the old user's messages.
In addition, there are different tokens returned for development apps using the sandbox and distribution apps using the production system.
Since a single user might have your app installed on multiple devices legally (iPhone and iPad, for instance), it will be much safer to have a many to many relationship between users and device tokens, to be on the safe side.
And since you mentioned Urban Airship, you might find that our alias feature helps for this sort of thing; you can assign a non-unique alias to the different tokens in our end, and then we'll keep track of the mapping between your users and their device tokens. See the registration and push parts of the UA documentation.
Edit: An update because I saw some more upvotes on this old answer. As of iOS 7, device tokens are unique for each application, even on the same device.
According to apple latest doc:
Never cache device tokens in your app; instead, get them from the system when you need them. APNs issues a new device token to your app when certain events happen. The device token is guaranteed to be different, for example, when a user restores a device from a backup, when the user installs your app on a new device, and when the user reinstalls the operating system. Fetching the token, rather than relying on a cache, ensures that you have the current device token needed for your provider to communicate with APNs. When you attempt to fetch a device token but it has not changed, the fetch method returns quickly.
For more info check apple doc