亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 OneSignal 打開特定活動?

如何使用 OneSignal 打開特定活動?

LEATH 2021-06-01 09:49:47
我正在使用 onesignal 發送推送通知。我使用此示例代碼在用戶單擊推送通知時打開特定活動。如果我想打開另一個特定的活動,我應該怎么做? package com.moho.app;    import android.content.Intent;    import android.util.Log;    import android.widget.Toast;    import com.onesignal.OSNotificationAction;    import com.onesignal.OSNotificationOpenResult;    import com.onesignal.OneSignal;    import org.json.JSONObject;    public class MyNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {        // This fires when a notification is opened by tapping on it.        @Override        public void notificationOpened(OSNotificationOpenResult result) {            OSNotificationAction.ActionType actionType = result.action.type;            JSONObject data = result.notification.payload.additionalData;            String activityToBeOpened;            String activity;            //While sending a Push notification from OneSignal dashboard            // you can send an addtional data named "activityToBeOpened" and retrieve the value of it and do necessary operation            //If key is "activityToBeOpened" and value is "AnotherActivity", then when a user clicks            //on the notification, AnotherActivity will be opened.            //Else, if we have not set any additional data MainActivity is opened.            if (data != null) {                activityToBeOpened = data.optString("activityToBeOpened", null);                if (activityToBeOpened != null && activityToBeOpened.equals("AnotherActivity")) {                    Log.i("OneSignalExample", "customkey set with value: " + activityToBeOpened);                    Intent intent = new Intent(MainMenu.getContext(), AboutUs.class);                    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);                    MainMenu.getContext().startActivity(intent);
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 179 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號