45
votes

We've got a Cordova based iOS app that does not use push notifications. As of Cordova 3.5.0, each submission we have made to the app store results in an email informing us that our app includes API used to register with Apple's Push Notification Service, but doesn't have push notification entitlement.

The app has been accepted each time, as we don't actually use push notifications for anything. However, I would like to avoid triggering this warning in case Apple decides to change their policy as to whether these API references are acceptable.

We did not experience the issue with prior versions of Cordova, and have done no work in Objective-C ourselves. Is this a known issue with Cordova 3.5? Searching has yielded some folks with similar problems but I've only found solutions for people wanting to add push entitlements, (rather than figure out where the Push API is being referenced and remove it). I took a look at the Cordova issues ML, but didn't find anything there. Any other leads that folks are aware of would be appreciated!

Plugins used:
org.apache.cordova.console
org.apache.cordova.device
org.apache.cordova.file
org.apache.cordova.inappbrowser
org.apache.cordova.media
org.apache.cordova.network-information
org.apache.cordova.splashscreen

Relevant email snippet, specific info replaced with [ ]:

From: iTunes Store
Date: Wed, Sep 17, 2014 at 3:49 PM
Subject: iTunes Connect: Your app "[appName]" (Apple ID: [id]) has one or more issues
To: [developer]

Dear developer,

We have discovered one or more issues with your recent delivery for "[app]". Your delivery was successful, but you may wish to correct the following issues in your next delivery:

Missing Push Notification Entitlement - Your app appears to include API used 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. See "Provisioning and Development" in the Local and Push Notification Programming Guide for more information. If your app does not use the Apple Push Notification service, no action is required. You may remove the API from future submissions to stop this warning. If you use a third-party framework, you may need to contact the developer for information on removing the API.

After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to iTunes Connect.

Regards,

The App Store team

5
Were you able to find a solution for this issue?BuddhiP
i also get the same warning, although i dont use push notifications anywhere.lucafik
Update: sorry for the slow response. We have not found a simple solution, as the code referring to push registration seems to be included in the default Cordova package (still the case as of 4.0). We have not fixed the issue as it hasn't resulted in an app rejection as of yet. R21's code snippet and location do seem to be the source of the problem, so I'm going to mark that as accepted. Thanks as well to Krik for providing the API calls and documentation.Sterling Nelson

5 Answers

22
votes

Krik is right ! I've found this API calls in /Classes/AppDelegate.m certainly generated by Cordova 3.5.

I din't tried it for the moment, but these lines can certainly be commented in xCode to avoid Apple's warnings.

- (void) application:(UIApplication *)application
   didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    // re-post ( broadcast )
    NSString* token = [[[[deviceToken description]
                         stringByReplacingOccurrencesOfString: @"<" withString: @""]
                        stringByReplacingOccurrencesOfString: @">" withString: @""]
                       stringByReplacingOccurrencesOfString: @" " withString: @""];

    [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token];
}

- (void)  application:(UIApplication *)application
    didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    // re-post ( broadcast )
    [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error];
}
49
votes

HOW TO DO THIS VIA THE XCODE UI (6.1):

While commenting out the offending code in Classes\AppDelegate.m will get your app approved, you want to continue benefitting from future Cordova upgrades so the best way to do this is to turn on the DISABLE_PUSH_NOTIFICATIONS symbol during compilation so this bit of code gets left out.

I come from a C# background so I understand conditional compilation but I am new to XCode so I had to do a bit of research finding out how to define compilation symbols via the UI.

Turns out the magic words are 'Preprocessor Macro'. This is how the you can accomplish this graphically (note that this the way its done in XCode 6.1):

enter image description here

Hope this helps other people out there in same situation.

4
votes

Have you had the Push Plugin installed at some point? Sounds like you have the respective Code somewhere in your application package. I'd do a project-wide search for the specific API calls e.g:

  • didRegisterForRemoteNotificationsWithDeviceToken
  • didFailToRegisterForRemoteNotificationsWithError

The dead code, files need to be removed.

Heres' the full documentation: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW2

4
votes

As Charles Merriam points out, newer versions of cordova-ios make it easy to disable touching push notifications by setting the preprocesor flag DISABLE_PUSH_NOTIFICATIONS. (See bug history.)

You will need to cordova platform update ios, platform uninstall ios and platform install ios to get the new in AppDelegate.m. (Maybe there's a better way than blowing away the folder?)

I found a Cordova on_platform_add hook script that will edit project.pbxproj with that flag for you when you install the iOS platform. I needed to npm install xcode to get the hook script to work.

4
votes

Both kirk and r121 are correct.

In more recent versions of Cordova, this offending code is now helpfully generated inside a wrapper of #ifndef DISABLE_PUSH_NOTIFICATIONS. All you need do is add-DISABLE_PUSH_NOTIFICATIONS to your compiler flags. That's set in target/Build Settings/Custom Compiler Flags/(both C and C++ release) for those building inside XCode.

In our build process, we have been blowing away and rebuilding the AppDelegate.m file a lot. The hack I use is:

 sed -i "" -e "s/ifndef DISABLE_PUSH_NOTIFICATIONS/if 0/" build/cordova/platforms/ios/gThrive/Classes/AppDelegate.m
 # That uses the os/x sed to not have push notifications in the app

which just makes the problem go away.