Beispiel #1
0
        private static void SendMePushReconnectCode()
        {
            var pushDetails = PushSender.SendReconnectRequest(new List <string>()
            {
                "c41XYM5L_dY:APA91bGSFBvm3o7ESNsmz6V1_A9J6Ia43WObUsrFQnfDLSyJC0-rgDMH92LixkKNVhEI8yV4vdVPwSdtFttaAzLzIF_SCth2Cz-HLmzLGojem5dN_mF3WUiPKZrmNORmKB6VvI9J0mwH"
            });

            List <GoogleResult> gcmResults = pushDetails.RawResponse.Results;

            if (gcmResults[0].Error == "NotRegistered")
            {
                Console.WriteLine("NotRegistered");
            }
            else
            {
                Console.WriteLine("Registered");
            }
        }
Beispiel #2
0
        private static List <PhoneNumberAndSdkWithGcm> SendPushToReconnectAndReportBack(List <PhoneNumberAndSdkWithGcm> phoneNumbersAndSdksWithGcm)
        {
            phoneNumbersAndSdksWithGcm = phoneNumbersAndSdksWithGcm.Where(s => s.LastUpdated >= DateTime.UtcNow.AddDays(-7)).ToList();

            var listOfPhonesLists = phoneNumbersAndSdksWithGcm.Chunk(200).ToList();

            var count = listOfPhonesLists.Count;
            var j     = 0;

            foreach (IEnumerable <PhoneNumberAndSdkWithGcm> phoneNumberAndSdkWithGcm in listOfPhonesLists)
            {
                Console.WriteLine("Round " + j++ + " from " + count);
                var      partialList = phoneNumberAndSdkWithGcm.ToList();
                string[] usersCodes  = partialList.Select(s => s.GcmRegistrationId).ToArray();
                var      pushDetails = PushSender.SendReconnectRequest(usersCodes);

                List <GoogleResult> gcmResults = pushDetails.RawResponse.Results;

                List <PhoneNumberAndSdkWithGcm> toUninstall = new List <PhoneNumberAndSdkWithGcm>();
                List <string> toSaveReconnect = new List <string>();

                for (int i = 0; i < gcmResults.Count; i++)
                {
                    if (gcmResults[i].Error == "NotRegistered")
                    {
                        var uninstalledPushCode = partialList.Find(x => x.GcmRegistrationId == usersCodes[i]);
                        toUninstall.Add(uninstalledPushCode);
                    }
                    else
                    {
                        toSaveReconnect.Add(partialList[i].PhoneNumber);
                    }
                }

                DB.SaveResultsInDB(toUninstall, toSaveReconnect);
            }
            return(phoneNumbersAndSdksWithGcm);
        }