Skip to content

Commit

Permalink
Merge pull request #7294 from cheekiatng/timob-19615-1_5_1_X
Browse files Browse the repository at this point in the history
[TIMOB-19615](5_1_X) Fix define for remote-notification and fetch in simulator
  • Loading branch information
cb1kenobi committed Oct 14, 2015
2 parents deb49b6 + f1476a6 commit 1076438
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4988,16 +4988,25 @@ iOSBuilder.prototype.processTiSymbols = function processTiSymbols() {

var dest = path.join(this.buildDir, 'Classes', 'defines.h'),
destExists = fs.existsSync(dest),
hasRemoteNotification = false,
hasFetch = false,
infoPlist = this.infoPlist,
contents;

delete this.buildDirFiles[dest];

if (Array.isArray(infoPlist.UIBackgroundModes) && infoPlist.UIBackgroundModes.indexOf('remote-notification') !== -1) {
hasRemoteNotification = true;
}
if (Array.isArray(infoPlist.UIBackgroundModes) && infoPlist.UIBackgroundModes.indexOf('fetch') !== -1) {
hasFetch = true;
}
// if we're doing a simulator build or we're including all titanium modules,
// return now since we don't care about writing the defines.h
if (this.target === 'simulator' || this.includeAllTiModules) {
var definesFile = path.join(this.platformPath, 'Classes', 'defines.h');

if (this.runOnMainThread && !this.useJSCore && !this.useAutoLayout) {
if (this.runOnMainThread && !this.useJSCore && !this.useAutoLayout && !hasRemoteNotification && !hasFetch) {
var contents = fs.readFileSync(definesFile).toString();
if ((destExists && contents === fs.readFileSync(dest).toString()) || !this.copyFileSync(definesFile, dest, { contents: contents })) {
this.logger.trace(__('No change, skipping %s', dest.cyan));
Expand Down Expand Up @@ -5052,11 +5061,10 @@ iOSBuilder.prototype.processTiSymbols = function processTiSymbols() {
contents = contents.join('\n');
}

var infoPlist = this.infoPlist;
if (Array.isArray(infoPlist.UIBackgroundModes) && infoPlist.UIBackgroundModes.indexOf('remote-notification') !== -1) {
if (hasRemoteNotification) {
contents += '\n#define USE_TI_SILENTPUSH';
}
if (Array.isArray(infoPlist.UIBackgroundModes) && infoPlist.UIBackgroundModes.indexOf('fetch') !== -1) {
if (hasFetch) {
contents += '\n#define USE_TI_FETCH';
}

Expand Down

0 comments on commit 1076438

Please sign in to comment.