apple-push-notifications interview questions
Top apple-push-notifications frequently asked interview questions
Is it possible to know if the app was launched/opened from a push notification?
I guess the launching event can be caught here:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions != nil) {
// Launched from push notification
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
}
}
However, how can I detect it was opened from a push notification when the app was on background?
Source: (StackOverflow)
Once created does the push notification device token ever change?
Example when the app is updated? or in any other case it can change??
Source: (StackOverflow)
I am trying to configure my app to support push notification, but keep getting this error:
Failed to get token, error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x1f818fc0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
- I did enable my app to support push notifications (only for development at this point).
- I did create the provisioning profile AFTER enabling the push notifications.
- My bundle identifier is the same as appears in the profile.
- In my profile file there is a string: aps-environment
- I made sure that in both project and target under the "Code signing identity" section ALL the values are selected to be my provisioning profile.
Any more ideas? Thanks.
Source: (StackOverflow)
I am making an application in which I want to implement apple push notification service. I am following the step-by-step instructions given in this tutorial.
But still, the methods are not called. I don't know what is causing the problem. Can anyone help me?
- (void)application:(UIApplication *)appdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//NSString * token = [[NSString alloc] initWithData:deviceTokenencoding:NSUTF8StringEncoding];
NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
NSLog(@"Device Token:%@",str);
//NSLog(@"Device token is called");
//const void *devTokenBytes = [deviceToken bytes];
//NSLog(@"Device Token");
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(@"Error:%@",str);
}
Source: (StackOverflow)
I have two apps on the iTunes store - both implement push notifications. While I was testing sending notifications to these production apps, I noticed that a push intended for app A was titled and opened app B.
Both of these apps are installed on the same phone. I looked in my device table and saw that the device Tokens (and of course, the Device ID) listed for the two apps were both the same.
As required, I am using two different certificates on the server - one for each app. I sort of assumed the device Token or certificate would route the message to the right app but clearly it isn't.
I can see in NSLog that the tokens being sent from each app are indeed the same.
Should the device Token be unique to each app? If so, any idea how my test phone could be sending the same device token for both apps to my server. Keep in mind this is from two apps currently on the app store.
Thanks for any help!
Source: (StackOverflow)
I was under the impression that when you use a development provisioning profile for a build of an app, only the specified developers can deploy that build to a phone.
But I just deployed a build that uses a development profile to a phone using Xcode Organizer, even though I'm not one of the valid developers for that profile. One of my colleagues, who doesn't even have Xcode installed, did the same with his phone using iTunes.
In that case, why not use a development provisioning profile for distributing your app to e.g. your QA team, instead of ad hoc distribution?
EDIT: Please read the part in bold carefully before answering. I'm not asking a basic "how does this work" question. I've made a lot of development, ad hoc, and app store builds, and now I find that I seem to have made some wrong assumptions.
Source: (StackOverflow)
I have something fairly simple I want to do. I attach a custom piece of data to some push notifications that I handle in
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
I look for the UIApplicationLaunchOptionsRemoteNotificationKey and hey presto there it is.
That method only gets called if my app is being launched for the first time. How do I read that same key if my application is running in the background already when the notification comes in and the user pressed the 'View' button on the notification? I want to send them to a particular view controller with that data open on it, the same as I do if the app is being launched for the first time from the notification.
Source: (StackOverflow)
I have an app for submission when it got rejected and I got the message
Missing Push Notification Entitlement - Your app appears to register
with the Apple Push Notification service, but the app signature's
entitlements do not include the "aps-environment" entitlement. If your
app uses the Apple Push Notification service, make sure your App ID is
enabled for Push Notification in the Provisioning Portal, and resubmit
after signing your app with a Distribution provisioning profile that
includes the "aps-environment" entitlement.
I checked my ad-hoc provisiong and there I found aps-environment and production however, when I open up my distribution provisioning, I don't find such.
Is this the cause of this error message and apple rejection, how can I fix it?
Source: (StackOverflow)
These kind of question has been asked a number of times but i have some specific situation going on.
When my application is active and I receive a PUSH message i'm successfully able to parse the custom payloads and such.
However when my application is in the background and the PUSH arrives the user has to click on the 'View/Open' button in order to get the didReceiveRemoteNotification
called and the didFinishLaunchingWithOptions
is called after that.
I need to have my application decide if they have to prompt the user with an UIAlert when in the background or suppress the push message based on some local settings.
Any help would be appreciated,
Source: (StackOverflow)
Here's the overview.
I need to add push notification to an iPhone app. Server side is ASP.NET in c#.
What I would like is some coaching to work through the process. I will then post generic code for an iPhone project and an ASP.NET web app along with step-by-step instructions so that others can learn.
Here is my understanding:
- Apply for APNS certificate and add it to keychain. (Not sure how to bring this to ASP.NET)
- Have iPhones register with registerForRemoteNotificationWithTypes, send the value to your server, and store in a DB. Seems like this code to register should be easy but I can't find a good sample. (No problem with sending the value to the ASP.NET server.)
- Your server app creates a payload string, does JSON encoding, sends to the APNS server for each (or can it be for groups) of iPhones using their device token that was saved into the DB.
So to develop the addition, here are the pieces:
The iPhone registration code
Code that sends iPhone registration code to server and saves to DB (this is easy and I already have these pieces).
The server side APNS contact code in c#. This also includes how to use the certificate that was generated on the Apple Developer web site.
Also, can the payload be a multiple choice question that can be answered with the result sent back to the server?
Thanks in advance for the help. I will turn this in to a tutorial for others.
Source: (StackOverflow)
I have an app on app store, which is using an iOS Provisioning Profile (Distribution) which is expired.
This Profile contains Push Certificate that's also expired (and does not appear anymore in the portal).
Question 1=
Is there a way to recreate the push certificate and then renew the profile? (I still have the push certificate (expired) on my keychain)
And\or
Question 2:
Do I need to re-submit the app to app store with a new profile that contains the new Push certificate?
Since the push certificate is expired, I can probably not send notifications to the existing users of the app.
Thanks for your help on this :)
F.
Source: (StackOverflow)
I'm looking for a way to determine if the user has, via settings, enabled or disabled their push notifications for my application.
Source: (StackOverflow)
I've been trying very very hard to create a simple simple iOS app which can recieve push notifications. My only reason for doing this is to establish a procedure for some other team members to use, and have not been able to find an up to date, working version of such instructions elsewhere on the web. Our shop is fairly new to iOS dev, I personally am completely inexperienced with iOS dev and Xcode. I've stumbled through tens of tutorials, articles, and trouble posts from Apple and elsewhere and I feel like I might be nearly there...
Here is where I've got to (note I'm using Xcode 4.3 and trying initially to deploy just to iOS 5.1, and I gather that some things may have changed recently vs earlier versions of Xcode, but again I'm new to all this -- and finding it completely confusing and convoluted):
1) I've got a provisioning profile on my iPhone which has Push enabled
2) In my test Xcode project I've got that provisioning profile selected as the signing identity (in Build Settings > Code Signing)

3) I've got my bundle identifier under Summary and Info > Custom iOS Target Properties set properly* (I think??)
4) I've got registerForRemoteNotificationTypes being called in my delegate's didFinishLaunchingWithOptions
5) I've got didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError in my delegate, set up to log the device token or error respectively
6) I've got Enable Entitlements checked under Summary.
7) Right below that the Entitlements File selected is Tinker6 (the name of my test project), which was generated automatically when I checked Enable Entitlements
8) In the Tinker6.entitlements file I've got the following (which I've gathered is correct based on several different posts all over the web, but which I can't find anything definitive from Apple itself on):

Updated
9) Also, I have tried the whole thing without an entitlements file, and get essentially the same result.
10) My mobileprovision file contents include entitlements properly (I've scrambled the number and domain but structurally the same):
<key>application-identifier</key>
<string>12355456A7.com.whatever.tinker</string>
<key>aps-environment</key>
<string>development</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>12355456A7.*</string>
</array>
/end update
When I attempt to run this on my device, I get the following error in Xcode output:
2012-06-11 12:45:23.762 Tinker6[13332:707] Failed to get token, error:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
entitlement string found for application" UserInfo=0x24a3b0
{NSLocalizedDescription=no valid 'aps-environment' entitlement string
found for application}
I've tried setting get-task-allow to NO, aps-environment to production, all four possible combinations, same thing.
How can I get past this? Where is definitive documentation on this?
-- further background follows --
*As far as the bundle id, I am still not clear on how this should be set in relation to App Ids and Profile ids in the Provisioning profile. In the Provisioning portal under App Ids I have this (again, scrambled the number and domain):

And the two places bundle id is set I have this:

I am not at all sure these are correct or whether one or both should be set to 12355456A7.com.whatever.tinker, though I've tried those earlier in the process with no success...
Note I realize there are many posts with similar titles, however they all seem to be out of date based on the file names and so-forth given, and the fact none of the solutions seem to be useful. I'm hoping the greater level of detail I've given will warrant a quality response. I will probably assign a bounty as soon as possible and if you give a high quality answer that leads to a solution I will award you the bounty as well as promote your answer via twitter and my blog. Especially if you crosspost post a really good "here are the exact 500 steps you need to get a simple push notification app working including provisioning and whatever else" article on your blog or whatever.
Source: (StackOverflow)
I tried and tried to generate .pem
file , every time generating certificates
from client's account and then generating .pem
file using terminal, but its of no use. i followed many links for the same. please help me if any one have any idea about how to generate .pem
or have any link that gives a step by step procedure for .pem
generation.
Source: (StackOverflow)