Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24580] iOS: SDK upgrade to 6.0.3.GA broke push notification registration

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-04-26T21:29:27.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.4
ComponentsiOS
Labelsn/a
ReporterShuo Liang
AssigneeChris Barber
Created2017-04-14T01:44:55.000+0000
Updated2017-04-27T17:49:59.000+0000

Description

Issue Detail

Building push notification enabled iOS app for enterprise distribution with TiSDK 6.0.3.GA produces this error when registering for push notifications:
no valid 'aps-environment' entitlement string found for application

Note

Building with 6.0.1.GA works as expected.

Reproduce

1. Add following code to default new project 2. Build for enterprise distribution 3. Install the generate ipa file on an iPhone 4. Launch the app 5. When prompted, allow push notifications 6. Observe the error in the alert "no valid 'aps-environment' entitlement string found for application"
var deviceToken = null;

// Check if the device is running iOS 8 or later
if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {

	// Wait for user settings to be registered before registering for push notifications
    Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {

        // Remove event listener once registered for push notifications
        Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);

        Ti.Network.registerForPushNotifications({
            success: deviceTokenSuccess,
            error: deviceTokenError,
            callback: receivePush
        });
    });

    // Register notification types to use
    Ti.App.iOS.registerUserNotificationSettings({
	    types: [
            Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
            Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
            Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
        ]
    });
}

// For iOS 7 and earlier
else {

    Ti.Network.registerForPushNotifications({
        // Specifies which notifications to receive
        types: [
            Ti.Network.NOTIFICATION_TYPE_BADGE,
            Ti.Network.NOTIFICATION_TYPE_ALERT,
            Ti.Network.NOTIFICATION_TYPE_SOUND
        ],
        success: deviceTokenSuccess,
        error: deviceTokenError,
        callback: receivePush
    });
}

// Process incoming push notifications
function receivePush(e) {
    alert('Received push: ' + JSON.stringify(e));
}
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
    deviceToken = e.deviceToken;
	alert('Successfully registered for push notifications!');
}

function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}

$.index.open();

Comments

  1. Hans Knöchel 2017-04-14

    Titanium SDK 6.0.3.GA requires Xcode 8.3 to be used, since the tooling was aligned to match the Xcode tooling. Please test regarding that and update this ticket afterwards. *EDIT*: Just tested with a fresh app using 6.0.3.GA and Xcode 8, copied the supplied code into the index.js and deployed it with a valid (push-entitled) provisioning profile to device and it works without issues. The used project is attached [here](https://www.dropbox.com/s/nylyk6qod58qckj/test_push.zip?dl=1). The generated entitlements file in build/iphone includes all required keys:
       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
       <plist version="1.0">
       <dict>
       	<key>application-identifier</key>
       	<string>6K4KHD4NQF.com.appc.pushtest</string>
       	<key>aps-environment</key>
       	<string>development</string>
       	<key>get-task-allow</key>
       	<true/>
       	<key>keychain-access-groups</key>
       	<array>
       		<string>6K4KHD4NQF.com.appc.pushtest</string>
       	</array>
       </dict>
       </plist>
       
    Resolving as Invalid for now.
  2. Andrew Rumbley 2017-04-26

    Hello, I'm who originally reported this issue to Axway. Thanks for looking into it Hans, but we've got some discrepancies in our results. When I build that test case using TiSDK 6.0.1 and Xcode 8.2.1 my entitlements file in build/iphone looks like this: {{ http://www.apple.com/DTDs/PropertyList-1.0.dtd"> application-identifier Z7HX3EQHHM.com.shockoe.push.test aps-environment production get-task-allow keychain-access-groups Z7HX3EQHHM.com.shockoe.push.test }} But when I build with TiSDK 6.0.3 and Xcode 8.3 it looks like this: {{ http://www.apple.com/DTDs/PropertyList-1.0.dtd"> }} Are you building for In House (enterprise) distribution? I see the aps-environment is set to development in your results, but I would expect it to be production.
  3. Hans Knöchel 2017-04-26

    I see. In my test-case, I didn't. Let me give that to our QE-team and reopen it.
  4. Eric Wieber 2017-04-26

    I am able to reproduce this issue, using Xcode 8.3.2 and SDK 6.0.3.GA. As described, the issue is not present when using Xcode 8.2.1 and SDK 6.0.1.GA. Andrew's/Shuo's steps are accurate for encountering the issue. Tested using an Enterprise, In House Distribution Profile for an Adhoc build with Push Services enabled. I see the same discrepancy in the entitlements files as Andrew posted, above.
  5. Chris Barber 2017-04-26

    Ti SDK master PR: https://github.com/appcelerator/titanium_mobile/pull/8998 Ti SDK 6_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/8999 Ti SDK 6_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/9000
  6. Eric Wieber 2017-04-26

    Verified fixed, in: MacOS 10.12 (16A323) Studio 4.8.1.201612050850 Appc NPM 4.2.9-3 Appc CLI 6.2.0 Alloy 1.9.11 Xcode 8.3.2 (8E2002) Performed enterprise adhoc/distribution builds with push enabled. Entitlements files were correctly populated and I was successfully able to register for push notifications. Confirmed fixed in SDK builds: 6.0.4.v20170426140226, 6.1.0.v20170426140837, and 6.2.0.v20170426140709
  7. Abir Mukherjee 2017-04-27

    An additional note, the Ti.Platform.name for iOS 10 and higher is now "iOS". So in the demo code above
       if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
       
    An additional condition needs to be added "Ti.Platform.name == iOS" For reference see "name" entry in: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform
  8. Andrew Rumbley 2017-04-27

    [~amukherjee] That's interesting. The sample code sets up correctly on iOS 10. Printing out Ti.Platform.name on iOS 10.3 Simulator shows it is still "iPhone OS".

JSON Source