【问题标题】:Urban Airship notification does not be shown in android device while message is being received接收消息时,Android 设备中不显示 Urban Airship 通知
【发布时间】:2014-10-31 12:30:02
【问题描述】:

我已将城市飞艇库集成到一个 android 项目中。 我的问题是我尝试通过城市飞艇仪表板中的测试推送通知发送消息。 虽然我在 logcat -> Received push message: Bundle[{com.urbanairship.push.ALERT=bla blaba etc 中看到,这意味着我收到了消息,但没有显示通知对话框。我究竟做错了什么? 此外,我添加了意图接收器类并尝试添加自定义通知对话框,但没有任何效果。在 IntentReceiver 类中,被调用的函数是

protected void onBackgroundPushReceived(Context context, PushMessage message)

但不是

onPushReceived(Context context, PushMessage message, int notificationId)

谢谢。

【问题讨论】:

  • 您不需要自定义通知对话框。你能分享你采取的步骤吗?另外你怎么称呼 UAirship.takeOff ?
  • 好吧,我认为一切都已正确设置。通过检查 IntentReceiver.class 中的 logcat,我看到正在调用 onBackgroundPushReceived(Context context, PushMessage message) 而不是 onPushReceived(Context context, PushMessage message, int notificationId) 将显示通知。我无法弄清楚它为什么会发生! :-( 顺便说一句,城市图书馆 android 示例运行良好..
  • 你能分享你的myApplication类吗?
  • super.onCreate(); UAirship.takeOff(this, new UAirship.OnReadyCallback() { @Override public void onAirshipReady(UAirship airship) { // 在此处执行任何飞艇配置 airship.getPushManager().setPushEnabled(true); } });
  • 我明白了。检查我的答案是否有效。让我知道。

标签: android push-notification alert urbanairship.com


【解决方案1】:
        //Change your UAirship.takeoff() to this :

        //Urban Airship
         AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(getApplicationContext());

        // Take off initializes the services
        UAirship.takeOff(this, options); 
        UAirship.shared().getPushManager().setUserNotificationsEnabled(true);

  //From this

  UAirship.takeOff(this, new UAirship.OnReadyCallback() { 
     @Override public void onAirshipReady(UAirship airship) { 
             // Perform any airship configurations here 
             airship.getPushManager().setPushEnabled(true); 
   }); 

【讨论】:

  • 谢谢你拯救了我的星期六!!终于奏效了!!但是为什么它与您的代码一起工作?为什么城市飞艇样本与我发布的起飞代码没有问题?
  • 我检查了文档,它指定以上述方式起飞。周末愉快:)
  • 正确,PushManager 上的用户 setUserNotificationsEnabled(true) 需要设置。它可以从 onReadyCallback 或起飞后设置。两者之间的唯一区别是您是否想要异步起飞。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多