我使用鈦加速器作爲通知服務器的小應用程序,並使用pushwoosh作爲通知服務器。在收到推送通知後打開窗口時出現鈦加速器錯誤
在我INDEX.XML我有以下:
<Alloy>
\t <!-- Anddroid Window -->
\t <Window id="index" platform="android">
\t \t <Require type="view" id="firstscreen" src="firstscreen"/>
\t </Window>
\t <!-- iOS Window -->
\t <NavigationWindow id="nav" platform="ios">
\t \t <Window id="win1" backgroundColor="white">
\t \t \t <Require type="view" id="firstscreen" src="firstscreen"/>
\t \t </Window>
\t </NavigationWindow>
</Alloy>
其次index.js,其中i接收推送,並希望將用戶重定向到登錄例如JS,目的是從推送自定義值中打開相應的頁面,但是在這裏我簡單地進行測試。
if (OS_ANDROID) {
\t $.index.addEventListener('open', after_win_load);
\t $.index.open();
} else {
\t $.nav.addEventListener('open', after_win_load);
\t $.nav.open();
}
var pushwoosh = require('com.pushwoosh.module');
/*
* PUSHWOOSH
* */
pushwoosh.onPushOpened(function(e) {
var message = e.message;
var login = Alloy.createController('login').getView();
$.nav.open(login);
});
pushwoosh.initialize({
"application" : "XXXX-XXXXXX",
"gcm_project" : "XXXXXXXXXXX"
});
pushwoosh.registerForPushNotifications(
function(e) {
var pushToken = e.registrationId;
;
\t \t console.log('Push token ' + pushwoosh.getPushToken());
\t \t Alloy.Globals.resgisterId = e.registrationId;
},
function(e) {
var errorMessage = e.error;
console.log("Error during registration: " + e.error);
// alert('push error');
}
);
而最後login.xml和login.js
<Alloy>
\t <Window id="login" >
\t \t <ScrollView scrollingEnabled="true" contentWidth="Ti.UI.FILL" disableBounce="true">
\t \t \t <!-- Here another view -->
\t \t </ScrollView>
\t </Window>
</Alloy>
//// login.js is simple :
var args = $.args;
console.log('hey boy');
當收到推送通知,並點擊它重定向登錄 JS我有以下錯誤:
[WARN] : Creating [object login] in a different context than the calling function.
[WARN] : Creating [object __alloyId48] in a different context than the calling function.
[ERROR] : Script Error {
[ERROR] : column = 2330;
[ERROR] : line = 1;
[ERROR] : message = "null is not an object (evaluating 'a.__views.login.add')";
[ERROR] : sourceURL = "file:///var/containers/Bundle/Application/ADE5F25A-17A4-4197-98C7-0781216545A3/myApp.app/alloy/controllers/login.js";
[ERROR] : stack = "[email protected]:///var/containers/Bundle/Application/ADE5F25A-17A4-4197-98C7-0781216545A3/myApp.app/alloy/controllers/login.js:1:2330\[email protected]:///var/containers/Bundle/Application/ADE5F25A-17A4-4197-98C7-0781216545A3/myApp.app/alloy.js:1:5254\[email protected]:///var/containers/Bundle/Application/ADE5F25A-17A4-4197-98C7-0781216545A3/myApp.app/xpng.js:1:283\nfile:///var/containers/Bundle/Application/ADE5F25A-17A4-4197-98C7-0781216545A3/myApp.app/alloy/controllers/firstscreen.js:1:3855";
[ERROR] : }
我不知道哪裏出錯,你能不能幫我解決呢? 謝謝。
注意:如果我把Alloy.createController('login')。getView()。open()Pushwoosh事件 – Rahajason