Beispiel #1
0
        //More details: https://documentation.onesignal.com/docs/xamarin-sdk#section--notificationopened-
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message  = payload.body;
            string actionID = result.action.actionID;

            Console.WriteLine("GameControllerExample:HandleNotificationOpened: " + message);
            string extraMessage = "Notification opened with text: " + message;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("discount"))
                {
                    extraMessage = (string)additionalData["discount"];
                    // Take user to your store.
                }
            }
            if (actionID != null)
            {
                // actionSelected equals the id on the button the user pressed.
                // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
                extraMessage = "Pressed ButtonId: " + actionID;
            }
        }
        //OneSignal Notification Received Method
        private static void HandleNotificationReceived(OSNotification notification)
        {
            OSNotificationPayload payload = notification.payload;
            string message = payload.body;

            test = message;
        }
Beispiel #3
0
        private void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message = payload.body;

            bool hasViewModel = additionalData.ContainsKey("User");
            bool hasTaskId    = additionalData.ContainsKey("TaskId");

            if (hasViewModel)
            {
                CrossSecureStorage.Current.SetValue("User", "user");

                return;
            }

            if (hasTaskId)
            {
                var taskObj = additionalData["TaskId"];

                string taskId = Convert.ToString(taskObj);

                CrossSecureStorage.Current.SetValue("TaskId", taskId);

                return;
            }

            ViewModel.ShowMain();
        }
Beispiel #4
0
    // Called when a notification is opened.
    // The name of the method can be anything as long as the signature matches.
    // Method must be static or this object should be marked as DontDestroyOnLoad
    public static void HandleNotificationOpened(OSNotificationOpenedResult result)
    {
        OSNotificationPayload payload = result.notification.payload;
        string message  = payload.body;
        string actionID = result.action.actionID;

        print("GameControllerExample:HandleNotificationOpened: " + message);
        extraMessage = "Notification opened with text: " + message;

        Dictionary <string, object> additionalData = payload.additionalData;

        if (additionalData == null)
        {
            Debug.Log("[HandleNotificationOpened] Additional Data == null");
        }
        else
        {
            Debug.Log("[HandleNotificationOpened] message " + message + ", additionalData: " + Json.Serialize(additionalData) as string);
        }

        if (actionID != null)
        {
            // actionSelected equals the id on the button the user pressed.
            // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
            extraMessage = "Pressed ButtonId: " + actionID;
        }
    }
        //OneSignal Notification Opening Handler
        public static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("imageURL"))
                {
                    imageURL = additionalData["imageURL"].ToString();
                }
                if (additionalData.ContainsKey("description"))
                {
                    description = additionalData["description"].ToString();
                }
                if (additionalData.ContainsKey("ytLink"))
                {
                    ytLink = additionalData["ytLink"].ToString();
                }
                if (additionalData.ContainsKey("productLabel"))
                {
                    productLabel = additionalData["productLabel"].ToString();
                }
                if (additionalData.ContainsKey("minQuantity"))
                {
                    minQuantity = additionalData["minQuantity"].ToString();
                }
                if (additionalData.ContainsKey("offerPrice1"))
                {
                    offerPrice1 = additionalData["offerPrice1"].ToString();
                }
                if (additionalData.ContainsKey("offerPrice2"))
                {
                    offerPrice2 = additionalData["offerPrice2"].ToString();
                }
                if (additionalData.ContainsKey("offerQuantity2"))
                {
                    offerQuantity2 = additionalData["offerQuantity2"].ToString();
                }
                if (additionalData.ContainsKey("offerPrice3"))
                {
                    offerPrice3 = additionalData["offerPrice3"].ToString();
                }
                if (additionalData.ContainsKey("offerQuantity3"))
                {
                    offerQuantity3 = additionalData["offerQuantity3"].ToString();
                }
                if (additionalData.ContainsKey("offerPrice4"))
                {
                    offerPrice4 = additionalData["offerPrice4"].ToString();
                }
                if (additionalData.ContainsKey("offerQuantity4"))
                {
                    offerQuantity4 = additionalData["offerQuantity4"].ToString();
                }
            }
            state = 1;
        }
Beispiel #6
0
    // Called when your app is in focus and a notificaiton is recieved.
    // The name of the method can be anything as long as the signature matches.
    // Method must be static or this object should be marked as DontDestroyOnLoad
    private static void HandleNotificationReceived(OSNotification notification)
    {
        OSNotificationPayload payload = notification.payload;
        string message = payload.body;

        print("GameControllerExample:HandleNotificationReceived: " + message);
        print("displayType: " + notification.displayType);
        extraMessage = "Notification received with text: " + message;
    }
 private async static void HandleNotificationOpened(OSNotificationOpenedResult result)
 {
     Session session = new Session();
     OSNotificationPayload       payload        = result.notification.payload;
     Dictionary <string, object> additionalData = payload.additionalData;
     string message       = payload.body;
     var    messageDialog = new MessageDialog(message);
     await messageDialog.ShowAsync();
 }
Beispiel #8
0
        // Called when a notification is opened.
        // The name of the method can be anything as long as the signature matches.
        // Method must be static or this object should be marked as DontDestroyOnLoad
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message      = payload.body;
            string actionID     = result.action.actionID;
            bool   isAppInFocus = result.notification.isAppInFocus;

            // Fire event
            NotificationOpened(message, actionID, additionalData, isAppInFocus);
        }
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            //Handle when notification clicked
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;

            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            editor.PutString("is_notification_received", "true");
            editor.Apply();
        }
        public static void HandleNotificationReceived(OSNotification notification)
        {
            OSNotificationPayload payload = notification.payload;

            if (payload.additionalData.TryGetValue("Types", out var types))
            {
                var t = types.ToString();
                //trả về parameter thích làm gì thì làm
                if (payload.additionalData.TryGetValue("Value", out var values))
                {
                }
                ;
            }
            ;
        }
    public void HandleNotificationOpened(OSNotificationOpenedResult result)
    {
        OSNotificationPayload payload = result.notification.payload;
        string message  = payload.body;
        string actionID = result.action.actionID;

        print("GameControllerExample:HandleNotificationOpened: " + message);
        //id = "Notification opened with text: " + message;
        Dictionary <string, object> additionalData = payload.additionalData;
//		if (actionID != null) {
//			OneSignal.IdsAvailable((userId, pushToken) => {
//				id  = "UserID:\n" + userId + "\n\nPushToken:\n" + pushToken;
//			});
//		}
    }
Beispiel #12
0
    // Called when a notification is opened.
    // The name of the method can be anything as long as the signature matches.
    // Method must be static or this object should be marked as DontDestroyOnLoad
    public static void HandleNotificationOpened(OSNotificationOpenedResult result)
    {
        SceneManager.LoadScene("OneSignalExampleScene");
        OSNotificationPayload payload = result.notification.payload;
        string message  = payload.body;
        string actionID = result.action.actionID;

        GameObject.Destroy(GameObject.Find("Camera2"));
        GameObject.Destroy(GameObject.Find("VirtualJoystick"));
        GameObject.Destroy(GameObject.Find("VirtualJoystick (1)"));
        GameObject.Destroy(GameObject.Find("Coin"));
        GameObject.Destroy(GameObject.Find("FB"));
        ///GameObject.Destroy(GameObject.Find("unitychan"));
        GameObject.Destroy(GameObject.Find("Facebook"));
        GameObject.Destroy(GameObject.Find("Pause"));
        GameObject.Destroy(GameObject.Find("CoinSound"));
        GameObject.Destroy(GameObject.Find("Fire"));
        GameObject.Destroy(GameObject.Find("Success"));
        GameObject.Destroy(GameObject.Find("status"));
        GameObject.Destroy(GameObject.Find("Cube"));
        GameObject.Destroy(GameObject.Find("Cube (1)"));
        GameObject.Destroy(GameObject.Find("FireAttackSound"));
        GameObject.Destroy(GameObject.Find("LoseSound"));
        GameObject.Destroy(GameObject.Find("WinSound"));
        GameObject.Destroy(GameObject.Find("goal1"));
        GameObject.Destroy(GameObject.Find("goal2"));
        GameObject.Destroy(GameObject.Find("goal3"));
        print("GameControllerExample:HandleNotificationOpened: " + message);
        extraMessage = "Notification opened with text: " + message;

        Dictionary <string, object> additionalData = payload.additionalData;

        if (additionalData == null)
        {
            Debug.Log("[HandleNotificationOpened] Additional Data == null");
        }
        else
        {
            Debug.Log("[HandleNotificationOpened] message " + message + ", additionalData: " + Json.Serialize(additionalData) as string);
        }

        if (actionID != null)
        {
            // actionSelected equals the id on the button the user pressed.
            // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
            extraMessage = "Pressed ButtonId: " + actionID;
        }
    }
Beispiel #13
0
        private void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;


            string message  = payload.body;
            string actionID = result.action.actionID;

            dataDependency = additionalData;
            // await MainPage.Navigation.PushAsync(new LatLongPushNotification());
            // print("GameControllerExample:HandleNotificationOpened: " + message);
            // extraMessage = "Notification opened with text: " + message;


            //    string extraMessage = (string)additionalData["location"];

            /*string data = message + " " + actionID;
             *
             *
             * if (additionalData != null)
             * {
             *  if (additionalData.ContainsKey("asigneeId"))
             *  {
             *      string extraMessage = Convert.ToString(additionalData["asigneeId"]);
             *      dataDependency = extraMessage;
             *      //await MainPage.Navigation.PushAsync(new JobDetails(extraMessage));
             *
             *
             *      // extraMessage = (string)additionalData["discount"];
             *      // Take user to your store.
             *  }
             *  //      else if (additionalData.ContainsKey("location"))
             *  //     {
             *  //     string extraMessage = (string)additionalData["location"];
             *
             *  //    await MainPage.Navigation.PushAsync(new LatLongPushNotification(extraMessage));
             *
             *  //  }
             * }
             * if (actionID != null)
             * {
             *  // actionSelected equals the id on the button the user pressed.
             *  // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
             *  //extraMessage = "Pressed ButtonId: " + actionID;
             * }*/
        }
    private void HandleNotificationReceived(OSNotification notification)
    {
        OSNotificationPayload payload = notification.payload;
        string message = payload.body;
        Dictionary <string, object> additionalData = payload.additionalData;



        if (additionalData == null)
        {
            Debug.Log("[HandleNotificationReceived] Additional Data == null");
        }
        else
        {
            var jsonString = JSON.Parse(Json.Serialize(additionalData) as string);

            PlayerPrefs.SetString("MultiBattle", jsonString["from"]);


            if (int.Parse(jsonString["from"]) == 99)
            {
                PlayerPrefs.SetInt("pos", 2);
                PlayerPrefs.SetString("RoomName", jsonString ["room"]);
                PlayerPrefs.SetString(Link.USER_2, PlayerPrefs.GetString(Link.FULL_NAME));
                PlayerPrefs.SetString(Link.USER_1, jsonString ["full_name_people"]);

                StartCoroutine(kurangEnergy());
            }
            else
            {
                if (PlayerPrefs.GetString(Link.INVITE_CLICK) != "TRUE")
                {
                    warningInvitating.SetActive(true);
                    warningInvitating.GetComponent <Warning> ().from             = PlayerPrefs.GetString("MultiBattle");
                    warningInvitating.GetComponent <Warning> ().idYangMengajak   = jsonString["idYangMengajak"].ToString();
                    warningInvitating.GetComponent <Warning> ().namaYangMengajak = jsonString["namaYangMengajak"].ToString();
                    warningInvitating.transform.FindChild("User").GetComponent <Text> ().text = warningInvitating.GetComponent <Warning> ().namaYangMengajak;
                    idajak   = jsonString ["idYangMengajak"];
                    namaajak = jsonString ["namaYangMengajak"];
                }
            }

            //confirming.text ="addtional data : "+Json.Serialize(additionalData) as string+"from : "+jsonString["from"]+"from2 : "+jsonString["from"].ToString()+"klik"+PlayerPrefs.GetString(Link.INVITE_CLICK);
        }
    }
Beispiel #15
0
        static Notification ToNotification(OSNotificationPayload payload)
        {
            var data = payload?
                       .additionalData?
                       .ToDictionary(
                y => y.Key,
                y => y.Value.ToString()
                )
                       ?? new Dictionary <string, string>(0);

            return(new Notification
            {
                Title = payload?.title,
                Message = payload?.body,
                BadgeCount = payload?.badge,
                Payload = data
            });
        }
Beispiel #16
0
    private static void HandleNotificationReceived(OSNotification notification)
    {
        OSNotificationPayload payload = notification.payload;
        string message = payload.body;

        print("GameControllerExample:HandleNotificationReceived: " + message);
        print("displayType: " + notification.displayType);

        Dictionary <string, object> additionalData = payload.additionalData;

        if (additionalData == null)
        {
            Debug.Log("[HandleNotificationReceived] Additional Data == null");
        }
        else
        {
            Debug.Log("[HandleNotificationReceived] message " + message + ", additionalData: " + Json.Serialize(additionalData) as string);
        }
    }
Beispiel #17
0
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message  = payload.body;
            string actionID = result.action.actionID;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("discount"))
                {
                    // Take user to your store.
                }
            }
            if (actionID != null)
            {
                // actionSelected equals the id on the button the user pressed.
                // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
            }
        }
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            Session session = new Session();
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;

            if (additionalData != null)
            {
                Frame  rootFrame = Windows.UI.Xaml.Window.Current.Content as Frame;
                string page      = additionalData["page"].ToString();
                if (page == "1")
                {
                    int    id_user_pelapor   = Convert.ToInt32(additionalData["id_user_pelapor"].ToString());
                    string nama_user_pelapor = additionalData["nama_user_pelapor"].ToString();
                    string id_laporan        = additionalData["id_laporan"].ToString();
                    string alamat_laporan    = additionalData["alamat_laporan"].ToString();
                    string tanggal_laporan   = additionalData["tanggal_laporan"].ToString();
                    string waktu_laporan     = additionalData["waktu_laporan"].ToString();
                    string judul_laporan     = additionalData["judul_laporan"].ToString();
                    string jenis_laporan     = additionalData["jenis_laporan"].ToString();
                    string deskripsi_laporan = additionalData["deskripsi_laporan"].ToString();
                    string lat_laporan       = additionalData["lat_laporan"].ToString();
                    string lng_laporan       = additionalData["lng_laporan"].ToString();
                    string tag = additionalData["tag"].ToString();
                    string thumbnail_gambar  = additionalData["thumbnail_gambar"].ToString();
                    int    status_laporan    = Convert.ToInt32(additionalData["status_laporan"].ToString());
                    int?   jumlah_konfirmasi = 0;
                    if (tag == "kriminalitas")
                    {
                        jumlah_konfirmasi = Convert.ToInt32(additionalData["jumlah_konfirmasi"].ToString());
                    }
                    else
                    {
                        jumlah_konfirmasi = null;
                    }
                    ReportDetailPageParams param = new ReportDetailPageParams(id_user_pelapor, nama_user_pelapor, id_laporan, alamat_laporan, tanggal_laporan, waktu_laporan, judul_laporan, jenis_laporan, deskripsi_laporan, lat_laporan, lng_laporan, tag, thumbnail_gambar, status_laporan, jumlah_konfirmasi);
                    session.setReportDetailPageParams(param);
                    rootFrame.Navigate(typeof(ReportDetailPage));
                }
            }
        }
Beispiel #19
0
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            List <NotifyModel>          payloadList    = new List <NotifyModel>();

            foreach (var item in payload.additionalData)
            {
                NotifyModel model = new NotifyModel()
                {
                    Id    = item.Key,
                    Value = item.Value.ToString()
                };
                payloadList.Add(model);
            }
            if (payloadList.Count != 0)
            {
                MessagingCenter.Send <Xamarin.Forms.Application, List <NotifyModel> >(App.Current, "info",
                                                                                      payloadList);
            }
        }
Beispiel #20
0
        // Called when a notification is opened.
        // The name of the method can be anything as long as the signature matches.
        // Method must be static or this object should be marked as DontDestroyOnLoad
        private static void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message  = payload.body;
            string actionID = result.action.actionID;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("codChamadaVeiculo"))
                {
                    //DateTime dtRecebimento = CrossSettings.Current.Get<DateTime>("dataRecebimentoChamada");
                    if (additionalData.ContainsKey("tempoEsperaAceitacao"))
                    {
                        string tempoEspera = additionalData["tempoEsperaAceitacao"].ToString();
                        CrossSettings.Current.Set("tempoEsperaAceitacao", tempoEspera);
                    }

                    //  var tempoEspera = CrossSettings.Current.Contains

                    var value = additionalData["codChamadaVeiculo"];
                    CrossSettings.Current.Set("ChamadaParaResposta", value.ToString());
                    //NavigationParameters param = new NavigationParameters();
                    //  param.Add("codChamada", value);
                    // if(actionID != null)
                    AppNavigationService.NavigateAsync("//NavigationPage/ResponderChamada", null, true);
                }
            }

            //if (actionID != null)
            //{
            //    if (actionID.Equals("__DEFAULT__"))
            //        AppNavigationService.NavigateAsync("Chamada");

            //    // actionSelected equals the id on the button the user pressed.
            //    // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
            //    // extraMessage = "Pressed ButtonId: " + actionID;
            //}
        }
    private static void HandleNotificationOpened(OSNotificationOpenedResult result)
    {
        OSNotificationPayload       payload        = result.notification.payload;
        Dictionary <string, object> additionalData = payload.additionalData;
        string message = payload.body;

        print("GameControllerExample:HandleNotificationOpened: " + message);

        if (additionalData != null)
        {
            if (additionalData.ContainsKey("notification"))
            {
                if (additionalData["notification"].Equals("offer"))
                {
                    Application.Quit();
                }
                else if (additionalData["notification"].Equals("confirm"))
                {
                    Application.Quit();
                }
            }
        }
    }
Beispiel #22
0
        // Called when your app is in focus and a notificaiton is recieved.
        // The name of the method can be anything as long as the signature matches.
        // Method must be static or this object should be marked as DontDestroyOnLoad
        private static void HandleNotificationReceived(OSNotification notification)
        {
            OSNotificationPayload payload = notification.payload;
            string message = payload.body;
            Dictionary <string, object> additionalData = payload.additionalData;

            if (additionalData != null)
            {
                if (additionalData.ContainsKey("mdn_area"))
                {
                    CrossSettings.Current.Set("atualizarDados", true);
                }
                if (additionalData.ContainsKey("logout"))
                {
                    CrossSettings.Current.Clear();
                    AppNavigationService.NavigateAsync("NavigationPage/Logar");
                }
                if (additionalData.ContainsKey("tempoEsperaAceitacao"))
                {
                    CrossSettings.Current.Set("dataRecebimentoChamada", DateTime.Now);
                }
            }
        }
Beispiel #23
0
    private void HandleNotificationReceived(OSNotification notification)
    {
        OSNotificationPayload payload = notification.payload;
        string message = payload.body;
        Dictionary <string, object> additionalData = payload.additionalData;

        warningInvitating.SetActive(true);


        if (additionalData == null)
        {
            Debug.Log("[HandleNotificationReceived] Additional Data == null");
        }
        else
        {
            var jsonString = JSON.Parse(Json.Serialize(additionalData) as string);

            //PlayerPrefs.SetString (Link.INVITE_ROOM, jsonString["invite_room"]);


            PlayerPrefs.SetString(Link.FOR_CONVERTING, jsonString["from"]);
            warningInvitating.SetActive(true);
            warningInvitating.GetComponent <Warning> ().from             = PlayerPrefs.GetString(Link.FOR_CONVERTING);
            warningInvitating.GetComponent <Warning> ().idYangMengajak   = jsonString["idYangMengajak"];
            warningInvitating.GetComponent <Warning> ().namaYangMengajak = jsonString["namaYangMengajak"];

            if (PlayerPrefs.GetString(Link.FOR_CONVERTING) == "2")
            {
                warningInvitating.transform.FindChild("name").GetComponent <Text> ().text = warningInvitating.GetComponent <Warning> ().namaYangMengajak;
            }
            else if (PlayerPrefs.GetString(Link.FOR_CONVERTING) == "3")
            {
                warningInvitating.transform.FindChild("name").GetComponent <Text> ().text = warningInvitating.GetComponent <Warning> ().namaYangMengajak + " Request To Join";
            }
        }
    }
        public OneSignalNotificationPayload(OSNotificationPayload _payload)
        {
            // iOS specific properties
            iOSSpecificProperties _iOSProperties = new iOSSpecificProperties();

            _iOSProperties.HasAction = (_payload.actionButtons != null) && (_payload.actionButtons.Count > 0);

            // Android specific properties
            AndroidSpecificProperties _androidProperties = new AndroidSpecificProperties();

            _androidProperties.ContentTitle = _payload.title;

            // Get user info dictionary by removing used property keys
            IDictionary _userInfoDict = new Dictionary <string, object>(_payload.additionalData != null ? _payload.additionalData : new Dictionary <string, object>());

            _userInfoDict.Remove(kTitleKey);

            // Set properties
            this.AlertBody         = _payload.body;
            this.iOSProperties     = _iOSProperties;
            this.AndroidProperties = _androidProperties;
            this.SoundName         = _payload.sound;
            this.UserInfo          = _userInfoDict;
        }
        public static void HandleNotificationReceived(OSNotification notification)
        {
            OSNotificationPayload payload = notification.payload;
            string message = payload.body;

            Console.WriteLine("message là: " + message);
            if (string.IsNullOrEmpty(message))
            {
                Console.WriteLine("noti trống");
            }

            var json = notification.payload.additionalData["content"].ToString();

            string[] datas = json.Split('~');
            switch (datas[1])
            {
            case "1":
                AddToCartAction(datas[0]);
                break;

            case "2":
                InsertOrderBillAction(datas[0]);
                break;

            case "3":
                ReturnProductCartAction(datas[0]);
                break;

            case "4":
                CancelOrderAction(datas[0]);
                break;

            case "5":
                ReceiveOrderAction(datas[0]);
                break;

            case "6":
                UpdateProductAction(datas[0]);
                break;

            case "7":
                AddProductAction(datas[0]);
                break;

            case "8":
                AnswerFeedbackAction(datas[0]);
                break;

            case "9":
                DeliverOrderAction(datas[0]);
                break;

            case "10":
                UpdateStoreAction(datas[0]);
                break;

            case "11":
                UpdateUserAction(datas[0]);
                break;

            case "12":
                LoginAction(datas[0]);
                break;

            case "13":
                SendReviewAction(datas[0]);
                break;
            }
        }
Beispiel #26
0
 // Construct the crossplatform OneSignalNotificationPayload by copying the OneSignal original payload.
 internal static OneSignalNotificationPayload ToCrossPlatformOSNotificationPayload(OSNotificationPayload payload)
 {
     return(Helper.CopyObjectData <OSNotificationPayload, OneSignalNotificationPayload>(payload));
 }
Beispiel #27
0
        private async void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            //result.notification.isAppInFocus = true;
            try
            {
                OSNotificationPayload       payload        = result.notification.payload;
                Dictionary <string, object> additionalData = payload.additionalData;


                string message  = payload.body;
                string actionID = result.action.actionID;

                // await MainPage.Navigation.PushAsync(new LatLongPushNotification());
                // print("GameControllerExample:HandleNotificationOpened: " + message);
                // extraMessage = "Notification opened with text: " + message;

                //    string extraMessage = (string)additionalData["location"];
                string data = message + " " + actionID;


                if (additionalData != null)
                {
                    if (additionalData.ContainsKey("asigneeId"))
                    {
                        string extraMessage = Convert.ToString(additionalData["asigneeId"]);
                        await MainPage.Navigation.PushAsync(new JobDetails(extraMessage));


                        // extraMessage = (string)additionalData["discount"];
                        // Take user to your store.
                    }
                    else if (additionalData.ContainsKey("SBProfileId"))
                    {
                        string extraMessage = Convert.ToString(additionalData["SBProfileId"]);
                        await MainPage.Navigation.PushAsync(new SmartBuyerProfile(extraMessage));
                    }

                    //      else if (additionalData.ContainsKey("location"))
                    //     {
                    //     string extraMessage = (string)additionalData["location"];

                    //    await MainPage.Navigation.PushAsync(new LatLongPushNotification(extraMessage));

                    //  }
                }
                else
                {
                    MainPage = new NavigationPage(new WelcomeTrolliPage());
                }


                if (actionID != null)
                {
                    // actionSelected equals the id on the button the user pressed.
                    // actionSelected will equal "__DEFAULT__" when the notification itself was tapped when buttons were present.
                    //extraMessage = "Pressed ButtonId: " + actionID;
                }
            }catch (Exception ex)
            {
                //Exception Class
            }
        }
Beispiel #28
0
 private static void HandleNotificationReceived(OSNotification notification)
 {
     OSNotificationPayload payload = notification.payload;
 }
Beispiel #29
0
        // Handle Notiications recieved via oneSignal and take appropriate actions
        private static async void HandleNotificationOpened(OSNotificationOpenedResult result)
        {
            OSNotificationPayload       payload        = result.notification.payload;
            Dictionary <string, object> additionalData = payload.additionalData;
            string message  = payload.body;
            string actionID = result.action.actionID;

            var extraMessage = "Notification opened with text: " + message;

            if (additionalData != null)
            {
                string id   = ""; //  the id of the object to open
                string kind = ""; // the kind of object the id belongs to and take relevant action to open page based on this

                if (additionalData.ContainsKey("id"))
                {
                    id = (additionalData["id"].ToString());
                }
                if (additionalData.ContainsKey("kind"))
                {
                    kind = (additionalData["kind"].ToString());
                }

                switch (kind)
                {
                case "Document":
                {
                    Document obj;

                    if (await CrossConnectivity.Current.IsRemoteReachable("https://www.google.com"))
                    {
                        obj = await DocumentsManager.GetAsync(id);
                    }
                    else
                    {
                        obj = await new StorageService <Document>().GetItemAsync(id);
                    }

                    if (obj != null)
                    {
                        await(tabbedNavigation._tabs[0].BindingContext as FreshBasePageModel).CoreMethods.PushPageModel <AddDocumentViewModel>(obj, true, Device.RuntimePlatform == Device.iOS);
                    }

                    break;
                }

                case "Teledeclaration":
                {
                    Teledeclaration obj;

                    if (await CrossConnectivity.Current.IsRemoteReachable("https://www.google.com"))
                    {
                        obj = await TeledeclarationsManager.GetAsync(id);
                    }
                    else
                    {
                        obj = await new StorageService <Teledeclaration>().GetItemAsync(id);
                    }

                    if (obj != null)
                    {
                        await(tabbedNavigation._tabs[0].BindingContext as FreshBasePageModel).CoreMethods.PushPageModel <TeledeclarationSecureActionViewModel>(obj, true, true);
                    }

                    break;
                }

                case "Ordonnance":
                {
                    Ordonnance obj;

                    if (await CrossConnectivity.Current.IsRemoteReachable("https://www.google.com"))
                    {
                        obj = await OrdonnanceManager.GetAsync(id);
                    }
                    else
                    {
                        obj = await new StorageService <Ordonnance>().GetItemAsync(id);
                    }

                    if (obj != null)
                    {
                        if (tabbedNavigation != null)
                        {
                            await tabbedNavigation.SwitchSelectedRootPageModel <OrdonnancesListViewModel>();
                        }

                        await(tabbedNavigation._tabs[2].BindingContext as FreshBasePageModel).CoreMethods.PushPageModel <OrdonnanceCreateEditViewModel>(obj, true);
                    }

                    break;
                }

                case "InvoiceToSecure":
                {
                    if (await CrossConnectivity.Current.IsRemoteReachable("https://www.google.com"))
                    {
                        var request  = new GetListRequest(20, 1, sortField: "createdAt", sortDirection: SortDirectionEnum.Desc);
                        var invoices = await InvoicesManager.GetListAsync(request);

                        if (invoices != null && invoices.rows != null && invoices.rows.Count > 0)
                        {
                            var invoice = invoices.rows.First();

                            if (invoice.FilePath.Contains(".pdf"))
                            {
                                await(tabbedNavigation._tabs[0].BindingContext as FreshBasePageModel).CoreMethods.PushPageModel <SecuriseBillsViewModel>(invoice, true);
                            }
                            else
                            {
                                await(tabbedNavigation._tabs[0].BindingContext as FreshBasePageModel).CoreMethods.PushPageModel <OrdonnanceViewViewModel>(invoice, true);
                            }
                        }
                    }
                    break;
                }

                default:
                    break;
                }
            }
        }
Beispiel #30
0
    /*** protected and private methods ****/
#if ONESIGNAL_PLATFORM
    private OSNotification DictionaryToNotification(Dictionary <string, object> jsonObject)
    {
        OSNotification        notification = new OSNotification();
        OSNotificationPayload payload      = new OSNotificationPayload();

        //Build OSNotification object from jsonString
        var payloadObj = jsonObject["payload"] as Dictionary <string, object>;

        if (payloadObj.ContainsKey("notificationID"))
        {
            payload.notificationID = payloadObj["notificationID"] as string;
        }
        if (payloadObj.ContainsKey("sound"))
        {
            payload.sound = payloadObj["sound"] as string;
        }
        if (payloadObj.ContainsKey("title"))
        {
            payload.title = payloadObj["title"] as string;
        }
        if (payloadObj.ContainsKey("body"))
        {
            payload.body = payloadObj["body"] as string;
        }
        if (payloadObj.ContainsKey("subtitle"))
        {
            payload.subtitle = payloadObj["subtitle"] as string;
        }
        if (payloadObj.ContainsKey("launchURL"))
        {
            payload.launchURL = payloadObj["launchURL"] as string;
        }
        if (payloadObj.ContainsKey("additionalData"))
        {
            if (payloadObj["additionalData"] is string)
            {
                payload.additionalData = Json.Deserialize(payloadObj["additionalData"] as string) as Dictionary <string, object>;
            }
            else
            {
                payload.additionalData = payloadObj["additionalData"] as Dictionary <string, object>;
            }
        }
        if (payloadObj.ContainsKey("actionButtons"))
        {
            if (payloadObj["actionButtons"] is string)
            {
                payload.actionButtons = Json.Deserialize(payloadObj["actionButtons"] as string) as Dictionary <string, object>;
            }
            else
            {
                payload.actionButtons = payloadObj["actionButtons"] as Dictionary <string, object>;
            }
        }
        if (payloadObj.ContainsKey("contentAvailable"))
        {
            payload.contentAvailable = (bool)payloadObj["contentAvailable"];
        }
        if (payloadObj.ContainsKey("badge"))
        {
            payload.badge = (int)payloadObj["badge"];
        }
        if (payloadObj.ContainsKey("smallIcon"))
        {
            payload.smallIcon = payloadObj["smallIcon"] as string;
        }
        if (payloadObj.ContainsKey("largeIcon"))
        {
            payload.largeIcon = payloadObj["largeIcon"] as string;
        }
        if (payloadObj.ContainsKey("bigPicture"))
        {
            payload.bigPicture = payloadObj["bigPicture"] as string;
        }
        if (payloadObj.ContainsKey("smallIconAccentColor"))
        {
            payload.smallIconAccentColor = payloadObj["smallIconAccentColor"] as string;
        }
        if (payloadObj.ContainsKey("ledColor"))
        {
            payload.ledColor = payloadObj["ledColor"] as string;
        }
        if (payloadObj.ContainsKey("lockScreenVisibility"))
        {
            payload.lockScreenVisibility = Convert.ToInt32(payloadObj["lockScreenVisibility"]);
        }
        if (payloadObj.ContainsKey("groupKey"))
        {
            payload.groupKey = payloadObj["groupKey"] as string;
        }
        if (payloadObj.ContainsKey("groupMessage"))
        {
            payload.groupMessage = payloadObj["groupMessage"] as string;
        }
        if (payloadObj.ContainsKey("fromProjectNumber"))
        {
            payload.fromProjectNumber = payloadObj["fromProjectNumber"] as string;
        }
        notification.payload = payload;

        if (jsonObject.ContainsKey("isAppInFocus"))
        {
            notification.isAppInFocus = (bool)jsonObject["isAppInFocus"];
        }
        if (jsonObject.ContainsKey("shown"))
        {
            notification.shown = (bool)jsonObject["shown"];
        }
        if (jsonObject.ContainsKey("silentNotification"))
        {
            notification.silentNotification = (bool)jsonObject["silentNotification"];
        }
        if (jsonObject.ContainsKey("androidNotificationId"))
        {
            notification.androidNotificationId = Convert.ToInt32(jsonObject["androidNotificationId"]);
        }
        if (jsonObject.ContainsKey("displayType"))
        {
            notification.displayType = (OSNotification.DisplayType)Convert.ToInt32(jsonObject["displayType"]);
        }

        return(notification);
    }