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();
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:Resolving as Invalid for now.
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">I see. In my test-case, I didn't. Let me give that to our QE-team and reopen it.
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.
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
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
An additional note, the Ti.Platform.name for iOS 10 and higher is now "iOS". So in the demo code above
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
[~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".