【问题标题】:Notification received but not showing收到通知但未显示
【发布时间】:2013-07-15 19:34:54
【问题描述】:

我正在向我的 Android 应用程序添加 Urban Airship 推送通知。当我发送测试推送时,我的自定义 BroadcastReceiver 正在接收通知。这是onReceive() 方法。

public class IntentReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent == null)
            return;

    String action = intent.getAction();

    if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
        int id = intent.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, 0); //Breakpoint here

        Log.w("my app", "Received push notification. Alert: "
                + intent.getStringExtra(PushManager.EXTRA_ALERT)
                + " [NotificationID="+id+"]");

        logPushExtras(intent);

    } else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
        //Other stuff here
    }

执行在断点处停止(注释中显示的位置)并记录详细信息。

但通知区域中不显示任何通知。在我的另一个带有 UA 推送通知的应用程序中,我认为这就是我所做的一切,但这次似乎不起作用。

我怀疑我在清单文件中做错了什么,或者我忘记在某个地方实现一个类。

有什么想法吗?

额外信息

扩展应用:

public class ExtendedApplication extends Application {

    public void onCreate(){
        AirshipConfigOptions options = AirshipConfigOptions.loadDefaultOptions(this);
        UAirship.takeOff(this, options);
        PushManager.enablePush();

        PushPreferences prefs = PushManager.shared().getPreferences();
        Log.e("my app", "My Application onCreate - App APID: " + prefs.getPushId());

        PushManager.shared().setIntentReceiver(IntentReceiver.class);
    }
}

编辑

我试过添加

PushManager.shared().setNotificationBuilder(new BasicPushNotificationBuilder());

按照this 帖子中的建议发送到我的 ExtendedApplication。

【问题讨论】:

    标签: android notifications urbanairship.com


    【解决方案1】:

    我从 UA 站点发送了一个带有空白“警报”字段的测试推送。我尝试了一些文本,现在它可以工作了。我不知道为什么,但我认为这不应该默默地失败。

    故事的寓意:不要将警报字段留空。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2020-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-01
      • 1970-01-01
      相关资源
      最近更新 更多