Missing Push Notification Entitlement

I just put the application in apple . apple sent me a mesasge

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.

knowing that I did not use the notification in my project

1 Like

Interesting, I’ve never seen this before. What plugins do you have added to your project?

I have had the same response, the list of plugins I have in my project are:

  • nl.x-services.plugins.toast
  • org.apache.cordova.device
  • org.apache.cordova.file-transfer
  • org.apache.cordova.network-information
  • com.ionic.keyboard
  • nl.x-services.plugins.socialsharing
  • org.apache.cordova.console
  • org.apache.cordova.file
  • org.apache.cordova.inappbrowser

If in your implementation you don 't have used the notification, delete the three methods in the file AppDelegate.m

// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond
- (void) application: (UIApplication ) application*
didReceiveLocalNotification: ( UILocalNotification*)notification
{
// re-post ( broadcast )
[[NSNotificationCenter defaultCenter] postNotificationName: CDVLocalNotification object:notification];
}

*- (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];
}

and delete this line in (

// all plugins will get the notification, and their handlers will be called
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];

)

in - (BOOL)application: (UIApplication )application openURL: (NSURL )url sourceApplication: ( NSString* )sourceApplication annotation: (id)annotation

and normally it should be accepted by Apple :slight_smile:

I have received this same warning. However, I believe that since I am not using push notifications there should be no issue. At least, that is what I gather from the above quote. Has anyone had experience otherwise?

I’m getting the same issue, even after I thought I added the entitlements to the App ID. I guess I’ll try removing those methods in AppDelegate? Did that work for anyone else?

What is the common denominator here? PhoneGap perhaps?

Or PhoneGap 3.5?

On the PGB forums there is a recognised issue with this particular error and PGB 3.5. It does not exists on 3.4 and appears to not cause App Store rejects though. I submitted to the App Store yesterday, with PG 3.5 and I got this error. Will feedback.

I’ve submitted and updated twice an app in the App Store over the past month. I’ve got the same warning each time. I haven’t had any issues.

2 Likes

What warning …??
Can you explain in detail ? May be i can help you…

Yep … same problem for me today.
I don’t use push notifications in my app!

I think that Apple found some function related to Push Notification and the only one I’ve found is in ngCordova.

me to! Apple wont care though it seems…

Got the same warning myself today, on a project I used Phonegap/cordova 3.5 for (not ionic) so it seems to be cordova based if you guys are getting it for ionic.

Also like you guys, my app has nothing to do with push notifications.

Same issue with me. I also got same response from apple. Even i am not using Apple Push Notification in my App.

How to solve this issue? Please help me regarding this.

Thanks

It says that if you’re not using Push Notification, then no action is required. So I would just wait until they accept or deny your app submission. That’s what I’m doing. This just seems to be more of a warning than a “denied” message.

Just feeding back.

My app was accepted fine even with this error.

1 Like

Same issue here. I’m not using push notifications but I’m also getting this warning. Perhaps some faulty defaults in the new cordova-ios 3.7.0?

Hi,

I am not sure if this helps but I fixed the problem as follows:

  1. Create a hook to remove the offending functions from AppDelegate.m.
  2. Invoked the hook for the ios platform during “after_prepare” in config.xml.

HOOK: ios-remote-notification-fix.js

The hook looks like this. Please note that you will have to change MyApp in the fn setting to your app name.

#!/usr/bin/env node

// ================================================================
// Read the platforms/ios/<appname>/Classes/AppDelegate.m
// and comment out the following functions:
// 1. didRegisterForRemoteNotificationsWithDeviceToken
// 2. didFailToRegisterForRemoteNotificationsWithError
// ================================================================
var fs = require('fs');
var sys = require('sys')

sys.puts('');
sys.puts('# ================================================================');
sys.puts('# HOOK: ios-remote-notification-fix.js');
sys.puts('# ================================================================');

// The file to change (and its backup).
var fn = 'platforms/ios/MyApp/Classes/AppDelegate.m';
var fno = fn + '.orig';  // backup

// Make sure that this hook is re-entrant.
if (fs.existsSync(fn) && !fs.existsSync(fno)) {
    sys.puts('INFO: creating ' + fno);
    fs.writeFileSync(fno, fs.readFileSync(fn));
    fs.readFile(fn, function(err, data) {
        if (!data) {
            sys.puts('ERROR: could not read file: "' + fn + '"');
            process.exit(1);
        }
        sys.puts('INFO: read ' + fn);
        sys.puts('INFO:   ' + data.length + ' bytes');

        // Convert to lines for parsing.
        var lines = [];
        var line = '';
        for(var i=0; i<data.length; i++) {
            var ch = String.fromCharCode(data[i]);
            line += ch;
            if (data[i] == 10) {
                lines.push(line);
                line = '';
            }
        }
        if (line.length > 0) {
            lines.push(line);
        }
        sys.puts('INFO:   ' + lines.length + ' lines');
        
        // Filter out the functions in question using line parsing.
        var fcts = [ 'didRegisterForRemoteNotificationsWithDeviceToken',
                     'didFailToRegisterForRemoteNotificationsWithError'];
        var newlines = [];
        var start = 0;
        for(var i=0; i<lines.length; i++) {
            var line = lines[i];

            // See if one of the functions is found. If it is
            // we are one line beyond what needs to be filtered
            // out.
            //
            // Example:
            //
            //   - (void)                                 application:(UIApplication*)application
            //     didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
            // {
            //     // re-post ( broadcast )
            //     [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error];
            // }
            //
            var found = false;
            for(var j=0; j<fcts.length; j++) {
                if (line.indexOf(fcts[j]) >=0 ) {
                    found = true;
                    break
                }
            }

            // The function was found, ignore it.
            if (found) {
                // We are one past the lines to ignore.
                var end = i - 1;
                for(var j=start; j<end; j++) {
                    newlines.push(lines[j]);
                }
                
                // Skip the function code and reset start.
                for(; i<lines.length; i++) {
                    line = lines[i];
                    var j = line.indexOf('}');
                    if (j >= 0 && j <= 2) {
                        // + 2 because we know by inspection that there is
                        // a trailing empty line.
                        start = i + 2;
                        break;
                    }
                }
            }
        }
        for(var i=start; i<lines.length; i++) {
            var line = lines[i];
            // Handle the case where the last line does not end with a new line.
            if (line.indexOf('\n') < 0) {
                line += '\n';
            }
            newlines.push(line);
        }
        var newdata = newlines.join('');
        sys.puts('INFO: writing ' + fn);
        sys.puts('INFO:   ' + newdata.length + ' bytes');
        sys.puts('INFO:   ' + newlines.length + ' lines');
        fs.writeFileSync(fn, newdata);
    });
}

sys.puts('# ================================================================');
sys.puts('# DONE: ios-remote-notification-fix.js');
sys.puts('# ================================================================');

config.xml

The config.xml entry looks like this:

<platform name="ios">
  <hook type="after_prepare" src="hook_scripts/ios-remote-notification-fix.js" />
</platform>

Cheers,

Joe

4 Likes

Where in the config.xml should I insert this js file? Inside widget tag or outside widget tag?

Great Stuff, thanks Joe.

@Hughred22: outside. Usually, nothing goes outside a root tag in XML

For me the same problem today , i’ve opened also another post with other itunes connect problems