Open android app from PUSH notification

前端 未结 4 1387
独厮守ぢ
独厮守ぢ 2021-02-06 02:41

Got a little problem that\'s been bugging me..

I\'ve set up my application to receive PUSH notifications from Urban Airship and that all works fine, but when I tap on a

4条回答
  •  迷失自我
    2021-02-06 03:15

    Following one of their sample projects (https://github.com/urbanairship/android-samples/tree/master/app/src/main/java/com/urbanairship/sample), you can extend the AirshipReceiver class and then override the onReceive method. This did the trick for me:

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
    
        String action = intent.getAction();
        if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
            Intent launch = new Intent(Intent.ACTION_MAIN);
            launch.setClass(UAirship.shared().getApplicationContext(), MyHome.class);
            launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            launch.putExtra("doWhatever",true);
            UAirship.shared().getApplicationContext().startActivity(launch);
        }
    
    }
    

提交回复
热议问题