Exemple #1
0
 public static void AddInstaApi(IInstaApi api)
 {
     if (api != null)
     {
         if (InstaApiList.Count == 0)
         {
             InstaApiList.Add(api);
         }
         else
         {
             try
             {
                 if (InstaApiList.Any(x => x.GetLoggedUser().UserName.ToLower() != api.GetLoggedUser().UserName.ToLower()))
                 {
                     InstaApiList.Add(api);
                 }
             }
             catch { InstaApiList.Add(api); }
         }
     }
 }
Exemple #2
0
        public void LoggedOut() // logout is completed?
        {
            var switchToAnotherAccount = false;

            if (InstaApiList.Count > 0)
            {
                InstaApiList.RemoveInstaApi(InstaApi);
                InstaApi = null;
                if (InstaApiList.Count > 0)
                {
                    InstaApi = InstaApiList[0];
                    switchToAnotherAccount = true;
                }
                SessionHelper.DontSaveSettings = true;
            }

            if (!switchToAnotherAccount)
            {
                SetStackPanelTitleVisibility(Visibility.Collapsed);
                NavigationService.Navigate(typeof(Views.Sign.SignInView));
            }
            else
            {
                InstaApiSelectedUsername = InstaApi.GetLoggedUser().UserName.ToLower();
                SettingsHelper.SaveSettings();
                try
                {
                    NavigationService.HideBackButton();
                }
                catch { }
                UserChanged = true;
                try
                {
                    Current.NavigateToMainView(true);
                }
                catch { }
            }
            "You've Been Logged Out.".ShowMsg();
            NavigationService.RemoveAllBackStack();
        }
Exemple #3
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            //{
            //  "Title": null,
            //  "Message": "Minista App (@ministaapp) has requested to follow you.",
            //  "TickerText": null,
            //  "IgAction": "user?username=ministaapp",
            //  "CollapseKey": "private_user_follow_request",
            //  "OptionalImage": null,
            //  "OptionalAvatarUrl": "https://instagram.fevn1-1.fna.fbcdn.net/v/t51.2885-19/s150x150/62231151_371563176829566_537134867805110272_n.jpg?_nc_ht=instagram.fevn1-1.fna.fbcdn.net&_nc_ohc=_S4Ei3Q3ZDsAX-HVjOo&tp=1&oh=384bd91ead130669a6eba37288050aaa&oe=5FF226E3",
            //  "Sound": null,
            //  "PushId": "5b59a0b8cd64eHa61202a11H5b59a5522d920H4b",
            //  "PushCategory": "private_user_follow_request",
            //  "IntendedRecipientUserId": "44579170833",
            //  "SourceUserId": "1647718432",
            //  "IgActionOverride": null,
            //  "BadgeCount": {
            //    "Direct": 0,
            //    "Ds": 0,
            //    "Activities": 0
            //  },
            //  "InAppActors": null
            //}

            //var p = new PushNotification
            //{
            //    Message = "ministaapp just posted an IGTV video.",//"2449256854614833779_1647718432"
            //    IgAction = "tv_viewer?id=2457508981540087540",
            //    CollapseKey = "subscribed_igtv_post",
            //    OptionalAvatarUrl = "https://instagram.fevn1-1.fna.fbcdn.net/v/t51.2885-19/s150x150/62231151_371563176829566_537134867805110272_n.jpg?_nc_ht=instagram.fevn1-1.fna.fbcdn.net&_nc_ohc=_S4Ei3Q3ZDsAX-HVjOo&tp=1&oh=384bd91ead130669a6eba37288050aaa&oe=5FF226E3",
            //    PushId = "5b5b4a70e31a8Ha61202a11H5b5b4f0a4347aH23",
            //    PushCategory = "subscribed_igtv_post",
            //    IntendedRecipientUserId = "44579170833",
            //    SourceUserId = "1647718432",
            //};
            //PushHelper.HandleNotify(p, InstaApiList);
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            openPicker.FileTypeFilter.Add(".json");

            var file = await openPicker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }
            var json = await FileIO.ReadTextAsync(file);

            var list = JsonConvert.DeserializeObject <cc>(json);

            foreach (var p in list)
            {
                PushNotification notification = new PushNotification
                {
                    Sound        = p.Sound,
                    SourceUserId = p.SourceUserId,
                    BadgeCount   = new BadgeCount
                    {
                        Activities = p.BadgeCount.Activities,
                        Direct     = p.BadgeCount.Direct,
                        Ds         = p.BadgeCount.Ds
                    },
                    CollapseKey             = p.CollapseKey,
                    PushCategory            = p.PushCategory,
                    IgAction                = p.IgAction,
                    IgActionOverride        = p.IgActionOverride,
                    InAppActors             = p.InAppActors,
                    IntendedRecipientUserId = p.IntendedRecipientUserId,
                    Message           = p.Message,
                    OptionalAvatarUrl = p.OptionalAvatarUrl,
                    OptionalImage     = p.OptionalImage,
                    PushId            = p.PushId,
                    TickerText        = p.TickerText,
                    Title             = p.Title,
                };
                PushHelper.HandleNotify(notification, InstaApiList.ToList());
            }
        }
Exemple #4
0
        //public static async Task LoadSession()
        //{
        //    try
        //    {
        //        CreateFolder();
        //        LocalFolder.Path.PrintDebug();
        //        var file = await LocalFolder.GetFileAsync(OldStateFile);
        //        var json = await FileIO.ReadTextAsync(file);
        //        if (string.IsNullOrEmpty(json))
        //            return;
        //        var content = Decrypt(json);
        //        content.PrintDebug();
        //        BuildApi();

        //        //await Task.Delay(350);

        //        await InstaApi.LoadStateDataFromStringAsync(content);

        //        return;
        //    }
        //    catch (Exception ex) { ex.PrintException("LoadSession ex"); }

        //    try
        //    {
        //        var file = await LocalFolder.GetFileAsync(StateFile);
        //        var json = await FileIO.ReadTextAsync(file);
        //        if (string.IsNullOrEmpty(json))
        //            return;
        //        var content = Decrypt(json);
        //        content.PrintDebug();
        //        BuildApi();
        //        await InstaApi.LoadStateDataFromStringAsync(content);

        //        return;
        //    }
        //    catch (Exception ex) { ex.PrintException("LoadSession ex"); }
        //}


        public static async Task LoadSessionsAsync()
        {
            try
            {
                LocalFolder.Path.PrintDebug();
                var files = await LocalFolder.GetFilesAsync();

                if (files?.Count > 0)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        var item = files[i];
                        if (item.Path.ToLower().EndsWith(SessionFileType))
                        {
                            try
                            {
                                var json = await FileIO.ReadTextAsync(item);

                                if (!string.IsNullOrEmpty(json))
                                {
                                    var content = Decrypt(json);
                                    content.PrintDebug();
                                    var api = BuildApi();
                                    await api.LoadStateDataFromStringAsync(content);

                                    InstaApiList.Add(api);
                                }
                            }
                            catch { }
                        }
                    }
                    if (InstaApiList.Count > 0)
                    {
                        if (string.IsNullOrEmpty(InstaApiSelectedUsername))
                        {
                            InstaApi = InstaApiList[0];


                            InstaApiSelectedUsername = InstaApi.GetLoggedUser().LoggedInUser.UserName.ToLower();
                        }
                        else
                        {
                            if (InstaApiList.Count == 1)
                            {
                                InstaApi = InstaApiList[0];
                            }
                            else
                            {
                                var first = InstaApiList
                                            .FirstOrDefault(x => x.GetLoggedUser()?.LoggedInUser.UserName.ToLower() ==
                                                            InstaApiSelectedUsername.ToLower());


                                if (first == null)
                                {
                                    InstaApi = InstaApiList[0];
                                }
                                else
                                {
                                    InstaApi = first;
                                }
                            }
                        }

                        "Loaded users:".PrintDebug();
                        foreach (var item in InstaApiList)
                        {
                            item.GetLoggedUser().UserName.ToLower().PrintDebug();
                        }

                        CurrentUser = InstaApi.GetLoggedUser().LoggedInUser.ToUserInfo();
                    }

                    //var apis = InstaApiList.ToList();
                    //if (InstaApi != null)
                    //    apis.AddInstaApiX(Helper.InstaApi);
                    //MultiApiHelper.SetupPushNotification(apis);
                }
            }
            catch (Exception ex) { ex.PrintException("LoadSession ex"); }
        }