Github user ligaz commented on a diff in the pull request: https://github.com/apache/cordova-ios/pull/128#discussion_r24230979 --- Diff: bin/templates/scripts/cordova/lib/push-notifications.js --- @@ -0,0 +1,82 @@ +(function () { + var fs = require('fs'), + path = require('path'), + exec = require('child_process').exec, + PUSH_NOTIFICATIONS_ENABLED_HEADER_FILE = 'PushNotificationsEnabled.h', + PUSH_NOTIFICATIONS_ENABLED_HEADER_FILE_CONTENT = '#define PUSH_NOTIFICATIONS_ENABLED ', + EXPANDED_PROVISIONING_PROFILE = process.env.EXPANDED_PROVISIONING_PROFILE, + PATH_TO_MOBILE_PROVISIONS = path.join(process.env.HOME, 'Library', 'MobileDevice', 'Provisioning Profiles'), + PROVISIONING_PROFILE_REQUIRED = process.env.PROVISIONING_PROFILE_REQUIRED, + PROVISIONING_PROFILE_UUID_REGEX = new RegExp('<key>UUID<\/key>[\\s\\S]*<string>' + EXPANDED_PROVISIONING_PROFILE + '<\/string>'); + + function logErrorIfExists(error) { + if (error !== null) { + console.error('ERROR: ' + error); + } + } + + function sanitizeMobileProvision(mobileProvision) { + if (mobileProvision.indexOf('.mobileprovision') === -1) { + mobileProvision += '.mobileprovision'; + } + + return mobileProvision; + } + + function createPushNotificationsEnabledHeaderFile(pushPluginsEnabled) { + var cordovaEnablePluginHeaderFileLocation = path.join(__dirname, '..', '..', process.env.PROJECT_NAME, 'Classes', PUSH_NOTIFICATIONS_ENABLED_HEADER_FILE); + fs.writeFileSync(cordovaEnablePluginHeaderFileLocation, PUSH_NOTIFICATIONS_ENABLED_HEADER_FILE_CONTENT + pushPluginsEnabled); + } + + function createPushNotificationsEnabledHeaderFileWithMobileProvision(mobileProvision) { + var pathToProvisioningProfile = path.join(PATH_TO_MOBILE_PROVISIONS, sanitizeMobileProvision(mobileProvision)); + + exec("security cms -D -i \"" + pathToProvisioningProfile + "\"", function (error, stdout, stderr) { + logErrorIfExists(error); + var pushPluginsEnabled = stdout.indexOf("<key>aps-environment</key>") > -1; + createPushNotificationsEnabledHeaderFile(pushPluginsEnabled); + }); + } + + function isprovisionUUIDSuitable(provisionContents) { + return PROVISIONING_PROFILE_UUID_REGEX.test(provisionContents); + } + + function findValidMobileProvision(provisions, successCallback, errorCallback) { --- End diff -- If you want to follow the node convention the errorCallback should be passed before the success one.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org