引用不在Mobile上运行的browserify包

时间:2016-11-07 22:54:45

标签: javascript android iphone cordova google-cloud-messaging

我无法在我的cordova应用程序中引用从browserify生成的bundle脚本。它在我尝试在浏览器上运行应用程序时有效。但我似乎无法让它在Android上运行。

notify.js

samplefinal =[]
for sub_list in results:
    for i, j in combinations(range(len(sub_list)), 2):
        out = ['', '']
        sample3 = []
        for pair in zip(sub_list[i], sub_list[j]):
            if '-' not in pair:
                out[0] += pair[0]
                out[1] += pair[1]
            sample3.append(out)
    samplefinal.append(sample3)
print samplefinal

Output: [[['111', '000'], ['111', '000'], ['111', '000']], [['000', '101'], ['000', '101'], ['000', '101']], [['000', '000'], ['000', '000'], ['000', '000']]]

在browserify之后,在终端中运行以下命令:

global.send_notification = function (){
    var gcm = require('node-gcm');
    var message = new gcm.Message();
    //API Server Key
    var sender = new gcm.Sender('[API KEY]');
    var registrationIds = [];

    // Value the payload data to send...
    message.addData('message',"\u270C This is a test push from Everything Under \u2764 from PhoneGap \u2706!");
    message.addData('title','TEST OFFER!' );
    message.addData('msgcnt','3'); // Shows up in the notification in the status bar
    //message.addData('soundname','beep.wav'); //Sound to play upon notification receipt - put in the www folder in app
    //message.collapseKey = 'demo';
    //message.delayWhileIdle = true; //Default is false
    message.timeToLive = 3000;// Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not specified.

    // At least one reg id required
    registrationIds.push(regId);

    /**
     * Parameters: message-literal, registrationIds-array, No. of retries, callback-function
     */
    sender.send(message, registrationIds, 4, function (result) {
        alert(result);
    }); 
}

我在main js文件之前的main.html文件中引用了 bundle_notify.js

browserify www/js/notify.js -o www/js/bundle_notify.js

调用send_notification()时没有任何反应;

它完全适用于浏览器,但是,当我尝试在我的Android设备上构建它时,它似乎无法工作。

任何帮助将不胜感激。

0 个答案:

没有答案