0
我正在將Urban Airship推送通知添加到我的Android應用。我發送測試推送時,我的自定義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());
我ExtendedApplication一個s在this後建議。