【发布时间】: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