Ti.Network.registerForPushNotifications no response
Khamis, 11 Jun 2015, 3:27 pm0
SDK: 3.5.1.GA, CLI: 4.0.1
Calling Ti.Network.registerForPushNotifications()
has no response, whether success, error or callback, basically no response at all. Turned out that the build script can’t detect the method and add USE_TI_NETWORKREGISTERFORPUSHNOTIFICATIONS
to defines.h during app compilation.
I created with a plugin that append the macro definition to *.pch file, here it is:
Create plugin folder:
cd $PROJECT_DIR mkdir -p plugins/ti.pushnotifsymbol/hooks touch plugins/ti.pushnotifsymbol/package.json touch plugins/ti.pushnotifsymbol/hooks/pushnotifsymbol.js
pushnotifsymbol.js:
exports.id = 'ti.pushnotifsymbol'; exports.cliVersion = '>=3.2'; exports.init = function (logger, config, cli) { var path = require('path'); var fs = require('fs'); var util = require('util'); var os = require('os'); var pchFile; var triggered = false; cli.on('build.pre.compile', function(builder, next) { pchFile = path.join(builder.buildDir, builder.tiapp.name + '_Prefix.pch'); next(); }); cli.on('build.ios.copyResource', function(builder, next) { if (!triggered) { triggered = true; if (fs.existsSync(pchFile)) { fs.appendFileSync(pchFile, os.EOL + '#define USE_TI_NETWORKREGISTERFORPUSHNOTIFICATIONS'); } } next(); }); };
Add <plugin>ti.pushnotifsymbol</plugin>
to <plugins>
section of your project tiapp.xml
Titanium Studio mark occurences
1 Julai 2015
11 Jun 2015