加速器和城市飞艇

发布于 2024-11-17 23:14:37 字数 1296 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

为人所爱 2024-11-24 23:14:37

这些模块对我来说总是时好时坏。

在没有进行大量故障排除的情况下,它们很少能正常工作。

我走了老派路线,它对我来说效果很好 - 尽管我确实更改了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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文