加速器和城市飞艇
我正在尝试使用 Appcelerator 来尝试 Urban Airship,但在使用时遇到问题。 这是我在 App.js 中的代码:
当用户打开应用程序时它会被“激活”,然后自动注册到 Urban Airship 吗?
UrbanAirship = require('ti.urbanAirship');
Ti.API.info("module is => "+UrbanAirship);
Ti.include('common/urbanairship.js');
UrbanAirship.key='XXX';
UrbanAirship.secret ='XXX';
UrbanAirship.master_secret='XXX';
UrbanAirship.baseurl = 'https://go.urbanairship.com';
Ti.Network.registerForPushNotifications({
types: [
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_SOUND
],
success:function(e){
var deviceToken = e.deviceToken;
Ti.API.info('successfully registered for apple device token with '+e.deviceToken);
var params = {
tags: ['version'+Ti.App.getVersion()],
alias: 'testing'
};
UrbanAirship.register(params, function(data) {
Ti.API.debug("registerUrban success: " + JSON.stringify(data));
}, function(errorregistration) {
Ti.API.warn("Couldn't register for Urban Airship");
});
},
error:function(e) {
Ti.API.warn("push notifications disabled: "+e);
},
callback:function(e) {
var a = Ti.UI.createAlertDialog({
title:'New Message',
message:e.data.alert
});
a.show();
}
});
I am trying out Urban Airship with Appcelerator but I am having problems with using it.
This is my code in App.js:
Will it be "activated" when the user opens the app and then register automatically with Urban Airship?
UrbanAirship = require('ti.urbanAirship');
Ti.API.info("module is => "+UrbanAirship);
Ti.include('common/urbanairship.js');
UrbanAirship.key='XXX';
UrbanAirship.secret ='XXX';
UrbanAirship.master_secret='XXX';
UrbanAirship.baseurl = 'https://go.urbanairship.com';
Ti.Network.registerForPushNotifications({
types: [
Ti.Network.NOTIFICATION_TYPE_BADGE,
Ti.Network.NOTIFICATION_TYPE_ALERT,
Ti.Network.NOTIFICATION_TYPE_SOUND
],
success:function(e){
var deviceToken = e.deviceToken;
Ti.API.info('successfully registered for apple device token with '+e.deviceToken);
var params = {
tags: ['version'+Ti.App.getVersion()],
alias: 'testing'
};
UrbanAirship.register(params, function(data) {
Ti.API.debug("registerUrban success: " + JSON.stringify(data));
}, function(errorregistration) {
Ti.API.warn("Couldn't register for Urban Airship");
});
},
error:function(e) {
Ti.API.warn("push notifications disabled: "+e);
},
callback:function(e) {
var a = Ti.UI.createAlertDialog({
title:'New Message',
message:e.data.alert
});
a.show();
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些模块对我来说总是时好时坏。
在没有进行大量故障排除的情况下,它们很少能正常工作。
我走了老派路线,它对我来说效果很好 - 尽管我确实更改了urbanairship.js以将windowfocus上的事件侦听器添加到最终应用程序中的寄存器/别名字段中。
但为了测试,请保持原样。希望这会有所帮助 - http://wiki.appcelerator.org/display/guides/Push+Notifications
The modules are always hit or miss for me.
Very rarely have they worked without a lot of troubleshooting.
I've gone the old-school route and it has worked fine for me - although I did change
urbanairship.js
to add eventlisteners on windowfocus to the register/alias fields in the final app.But for testing just leave as is. Hope this helps - http://wiki.appcelerator.org/display/guides/Push+Notifications