Пример #1
0
        public async void unsubscribe(string arg)
        {
            string channel = JsonHelper.Deserialize <string[]>(arg)[0];
            await ParsePush.UnsubscribeAsync(channel);

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, ""));
        }
Пример #2
0
        private async void sysMessage(String msg)
        {
            if (ApplicationData.Current.RoamingSettings.Values.ContainsKey("UserName"))
            {
                UserName = (String)ApplicationData.Current.RoamingSettings.Values["UserName"];
            }
            else
            {
                UserName = "******";
            }

            String    message = msg;
            ParsePush push    = new ParsePush();

            push.Channels = new List <String> {
                "testing"
            };
            IDictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("sound", ".");
            dic.Add("alert", message);
            push.Data = dic;
            await push.SendAsync();


            ParseObject internal_tweets = new ParseObject("TweetsInternal");

            internal_tweets["content"] = message;
            internal_tweets["sender"]  = UserName;
            await internal_tweets.SaveAsync();
        }
Пример #3
0
        protected void CreateChatRooms()
        {
            chatroomsAdapter = new ChatRoomsAdapter(this);
            var chatRoomsListView = FindViewById <ListView> (Resource.Id.chatroomsListView);

            chatRoomsListView.Adapter    = chatroomsAdapter;
            chatRoomsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
                var      intent       = new Intent(this, typeof(ChatRoomActivity));
                intent.PutExtra("chatroom", currChatRoom.webID);
                StartActivity(intent);
            };
            chatRoomsListView.ItemLongClick += async(object sender, AdapterView.ItemLongClickEventArgs e) => {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Do you want to delete this chatroom?");
                alert.SetPositiveButton("Yes", (senderAlert, args) => {
                    ChatRoom currChatRoom = chatroomsAdapter.GetChatRoomAt(e.Position);
                    ParsePush.UnsubscribeAsync(currChatRoom.webID);
                    ChatRoomUser cru = DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoomUser(DatabaseAccessors.CurrentUser().webID, currChatRoom.webID);
                    DatabaseAccessors.ChatRoomDatabaseAccessor.DeleteChatRoom(currChatRoom.webID);
                    ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase();
                    pcrd.DeleteChatRoomUserAsync(cru);
                    Console.WriteLine("ERASED");
                    chatroomsAdapter.NotifyDataSetChanged();
                });
                alert.SetNegativeButton("No", (senderAlert, args) => {
                });
                alert.Show();
            };
        }
Пример #4
0
        public Task TestSubscribe()
        {
            List <string> channels = new List <string>();

            ParsePushPlugins.Instance = new ParsePushPlugins
            {
                PushChannelsController = GetMockedPushChannelsController(channels)
            };

            channels.Add("test");
            return(ParsePush.SubscribeAsync("test").ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);

                return ParsePush.SubscribeAsync(new List <string> {
                    { "test" }
                });
            }).Unwrap().ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);

                CancellationTokenSource cts = new CancellationTokenSource();
                return ParsePush.SubscribeAsync(new List <string> {
                    { "test" }
                }, cts.Token);
            }).Unwrap().ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);
            }));
        }
Пример #5
0
        private void mousedMoved(object sender, PointerRoutedEventArgs e)
        {
            if (entered == true && exited == false)
            {
                running_counter++;
                if (running_counter == internal_counter)
                {
                    running_counter = 0;
                    counter--;
                    String location = "ms-appx:///Assets/" + counter + ".png";
                    (sender as Button).Background = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(location))
                    };
                }

                if (counter == 1)
                {
                    Debug.WriteLine("Trigger execution!!!!!!!!");
                    (sender as Button).Background = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Sent.png"))
                    };
                    Button but     = (sender as Button);
                    String message = "Neil -- " + but.Content.ToString();

                    //var push = new ParsePush();
                    //push.Channels = new List<string> { "Giants" };
                    //push.Alert = "The Giants just scored!";
                    //await push.SendAsync();



                    //Short version sending
                    //ParsePush.SendAlertAsync(message, "testing");

                    ParsePush push = new ParsePush();
                    push.Channels = new List <String> {
                        "global"
                    };
                    //    push.Alert = message;
                    IDictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("sound", ".");
                    dic.Add("alert", message);
                    push.Data = dic;
                    push.SendAsync();


                    ParseObject internal_tweets = new ParseObject("TweetsInternal");
                    internal_tweets["content"] = message;
                    internal_tweets["sender"]  = "Neil";
                    internal_tweets.SaveAsync();



                    entered = false;
                    exited  = true;
                }
            }
            //Debug.WriteLine(sender.GetHashCode() + "     Still in the button   " + running_counter);
        }
Пример #6
0
        public async Task RegisterForPush(IActivatedEventArgs args)
        {
            await ParsePush.SubscribeAsync("");

            await ParseInstallation.CurrentInstallation.SaveAsync();

            await ParseAnalytics.TrackAppOpenedAsync(args as LaunchActivatedEventArgs);
        }
Пример #7
0
        public void unsubscribe(string args)
        {
            var topic = JSON.JsonHelper.Deserialize <string[]>(args)[0].ToString();

            ParsePush.UnsubscribeAsync(topic);

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true));
        }
Пример #8
0
 private async void Subscribe()
 {
     try
     {
         await ParsePush.SubscribeAsync("global");
     } catch (Exception x) {
         // log
     }
 }
Пример #9
0
        async void SubmittOrders(double prices)
        {
            orderWaitTime.GetOrdersTotal = Source.ordersList.Count;
            time = orderWaitTime.CalculateWaitTime();
            AlertPopUp("Order on the way", "Your order will take about " + time + " minutes", "OK");
            string[] arrSplit = VouchersLabel.Text.Split(' ');
            voucherUpdate = int.Parse(arrSplit[0]);

            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            View.Add(loadingOverlay);

            try
            {
                TableNameOrders = new ParseObject("Orders");
                TableNameOrders["PersonOrdered"]        = GetName;
                TableNameOrders["OrderList"]            = items;
                TableNameOrders["Price"]                = prices;
                TableNameOrders["IsOrderDone"]          = false;
                TableNameOrders["OrderReceivedByAdmin"] = false;
                TableNameOrders["Time"]        = "" + time;
                TableNameOrders["UserChannel"] = GetUserChannelName;
                CurrentUser["Vouchers"]        = voucherUpdate;

                await TableNameOrders.SaveAsync();

                await CurrentUser.SaveAsync();

                items.Clear();

                //send push

                var push = new ParsePush();
                push.Channels = new List <string> {
                    "Admin"
                };

                push.Data = new Dictionary <string, object>
                {
                    { "alert", "New order from " + (GetName + " " + GetSurname).ToUpper() },
                    { "sound", "default" },
                    { "badge", "Increment" }
                };

                await push.SendAsync();

                Source.Ordered           = true;
                Source.GetInitialVoucher = voucherUpdate + " vouchers";
            }
            catch (ParseException q)
            {
                Debug.WriteLine(q.StackTrace);
            }

            ResetScreen();
            loadingOverlay.Hide();
        }
Пример #10
0
		protected async Task SynchronizeWithParse(){
			ParseChatItemDatabase parseDB = new ParseChatItemDatabase ();
			await parseDB.GetAndSyncChatItemsAsync (chatroom.webID);
			await ParsePush.SubscribeAsync (chatroom.webID);
			RunOnUiThread (() => chatsAdapter.NotifyDataSetChanged ());
			RunOnUiThread( () => FindViewById<ListView>(Resource.Id.chatsListView).SmoothScrollToPosition(chatsAdapter.GetCount() - 1));
			Console.WriteLine ("Synched chatroom");


		}
Пример #11
0
        private async void Send_Click(object sender, RoutedEventArgs e)
        {
            Status.Text += "\nSending push to all subscribers...";
            await ParsePush.SendDataAsync(new Dictionary <string, object> {
                { "title", PushTitle.Text },
                { "alert", PushAlert.Text },
            });

            Status.Text += "\nDone sending push.";
        }
Пример #12
0
        private void mousedMoved(object sender, PointerRoutedEventArgs e)
        {
            if (entered == true && exited == false)
            {
                running_counter++;
                if (running_counter == internal_counter)
                {
                    running_counter = 0;
                    counter--;
                    String location = "ms-appx:///Assets/" + counter + ".png";
                    (sender as Windows.UI.Xaml.Controls.Button).Background = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri(location))
                    };
                }

                if (counter == 1)
                {
                    if (ApplicationData.Current.RoamingSettings.Values.ContainsKey("UserName"))
                    {
                        UserName = (String)ApplicationData.Current.RoamingSettings.Values["UserName"];
                    }
                    else
                    {
                        UserName = "******";
                    }

                    Debug.WriteLine("Trigger execution!!!!!!!!");
                    (sender as Windows.UI.Xaml.Controls.Button).Background = new ImageBrush {
                        ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Sent.png"))
                    };
                    Windows.UI.Xaml.Controls.Button but = (sender as Windows.UI.Xaml.Controls.Button);
                    String message = but.Content.ToString();

                    ParsePush push = new ParsePush();
                    push.Channels = new List <String> {
                        "global"
                    };
                    IDictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("sound", ".");
                    dic.Add("alert", UserName + ": " + message);
                    // dic.Add("time", UserName);
                    push.Data = dic;
                    push.SendAsync();


                    ParseObject internal_tweets = new ParseObject("TweetsInternal");
                    internal_tweets["content"] = message;
                    internal_tweets["sender"]  = UserName;
                    internal_tweets.SaveAsync();

                    entered = false;
                    exited  = true;
                }
            }
        }
Пример #13
0
 private async void SubscribeForPush()
 {
     try
     {
         await ParsePush.SubscribeAsync("");
     }
     catch (Exception x)
     {
         // TODO: Log this!
     }
 }
Пример #14
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            ResultsPanel.Children.Clear();
            PrintString("Starting tests!");
            var query = ParseObject.GetQuery("GameScore");

            PrintString("Cleaning data");
            var gameScores = await query.FindAsync();

            if (gameScores != null)
            {
                foreach (var score in gameScores)
                {
                    await score.DeleteAsync();
                }
            }

            PrintString("Adding new GameScore {123, Anton}");
            var gameScore = new ParseObject("GameScore");

            gameScore["score"]      = 123;
            gameScore["playerName"] = "Anton";
            await gameScore.SaveAsync();

            PrintString("Added data");
            query     = ParseObject.GetQuery("GameScore");
            gameScore = await query.FirstAsync();

            Debug.Assert(gameScore.Get <string>("playerName").Equals("Anton"));
            Debug.Assert(gameScore.Get <int>("score").Equals(123));
            PrintString(string.Format("Retrieved data score : {0}, name: {1}", gameScore.Get <int>("score"),
                                      gameScore.Get <string>("playerName")));
            PrintString("Testing push");
            ParsePush.ToastNotificationReceived += (s, args) =>
            {
                var json = ParsePush.PushJson(args);
                Debug.Assert(json["title"].Equals("My test PN"));
                Debug.Assert(json["alert"].Equals("Hello Anton!"));
                PrintString(string.Format("Got push title: {0}, content: {1}", json["title"], json["alert"]));
            };

            var push = new ParsePush
            {
                Data = new Dictionary <string, object> {
                    { "title", "My test PN" }, { "alert", "Hello Anton!" }
                },
                Channels = new List <string> {
                    "myTesthannel"
                }
            };
            await push.SendAsync();

            PrintString("Push sent");
        }
Пример #15
0
 private async void Subscribe()
 {
     try
     {
         await ParsePush.SubscribeAsync("global");
     }
     catch (Exception x)
     {
         Debug.WriteLine(x);
     }
 }
Пример #16
0
        private async void _unsubscribe(string channel)
        {
            await ParsePush.UnsubscribeAsync(channel);
			
			PluginResult pr = new PluginResult(PluginResult.Status.OK, "onUnsubscribeSucceeded");
			pr.KeepCallback = true;
			DispatchCommandResult(pr);
			//PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
			//pr.KeepCallback = true;
			//DispatchCommandResult(pr);			
        }		
Пример #17
0
        public async void subscribe(string arg)
        {
            string channel = JsonHelper.Deserialize <string[]>(arg)[0];
            await ParsePush.SubscribeAsync(channel);

            if (hasRegisteredEvent == false)
            {
                registerEvent();
            }

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, ""));
        }
Пример #18
0
        public Task TestSendPush()
        {
            MutableServiceHub hub = new MutableServiceHub {
            };
            ParseClient client    = new ParseClient(new ServerConnectionData {
                Test = true
            }, hub);

            MutablePushState state = new MutablePushState
            {
                Query = Client.GetInstallationQuery()
            };

            ParsePush thePush = new ParsePush(client);

            hub.PushController = GetMockedPushController(state);

            thePush.Alert = "Alert";
            state.Alert   = "Alert";

            return(thePush.SendAsync().ContinueWith(task =>
            {
                Assert.IsTrue(task.IsCompleted);
                Assert.IsFalse(task.IsFaulted);

                thePush.Channels = new List <string> {
                    { "channel" }
                };
                state.Channels = new List <string> {
                    { "channel" }
                };

                return thePush.SendAsync();
            }).Unwrap().ContinueWith(task =>
            {
                Assert.IsTrue(task.IsCompleted);
                Assert.IsFalse(task.IsFaulted);

                ParseQuery <ParseInstallation> query = new ParseQuery <ParseInstallation>(client, "aClass");

                thePush.Query = query;
                state.Query = query;

                return thePush.SendAsync();
            }).Unwrap().ContinueWith(task =>
            {
                Assert.IsTrue(task.IsCompleted);
                Assert.IsFalse(task.IsFaulted);
            }));
        }
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
            this.InitializeComponent();

            ParseClient.Initialize("HRd8Mraru64H28mmcfwiO3A2gyK7wYeu5UQDMFN0", "OSF70riVhcE5RztikTGsri72w5uQgJmAWqGMCpz0");
            // After calling ParseClient.Initialize():
            this.Startup += async(sender, args) =>
            {
                // This optional line tracks statistics around app opens, including push effectiveness:
                ParseAnalytics.TrackAppOpens(RootFrame);

                // By convention, the empty string is considered a "Broadcast" channel
                // Note that we had to add "async" to the definition to use the await keyword
                await ParsePush.SubscribeAsync("");
            };
            ParsePush.ToastNotificationReceived += ParsePushOnToastNotificationReceived;
            //NavigationService.Navigate(new Uri("/BingMaps.xaml", UriKind.Relative));
        }
Пример #20
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			chatroom = DatabaseAccessors.ChatRoomDatabaseAccessor.GetChatRoom (Intent.GetStringExtra ("chatroom"));
			SetContentView (Resource.Layout.ChatRoom);
			chatsAdapter = new ChatAdapter (this);
			var chatsListView = FindViewById<ListView> (Resource.Id.chatsListView);
			chatsListView.Adapter = chatsAdapter;
			chatsListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {

			};

			var sendButton = FindViewById<Button> (Resource.Id.send_message_button);
			var textBoxEdit = FindViewById<EditText> (Resource.Id.chatInputTextBox);
			textBoxEdit.Click += (sender, e) => {
				RunOnUiThread( () => FindViewById<ListView>(Resource.Id.chatsListView).SmoothScrollToPosition(chatsAdapter.GetCount() - 1));
			};
			sendButton.Click += async (sender, e) => {
				EditText textEdit = FindViewById<EditText>(Resource.Id.chatInputTextBox);
				string messageContent = textEdit.Text.ToString();
				RunOnUiThread( () => textEdit.Text = "");
				ParseChatItemDatabase parseItemDB = new ParseChatItemDatabase();
				ChatItem chat = new ChatItem();
				chat.chatroomID = chatroom.webID;
				chat.senderID = DatabaseAccessors.CurrentUser().webID;
				chat.content = messageContent;

				await parseItemDB.SaveChatItemAsync(chat);
				DatabaseAccessors.ChatDatabaseAccessor.SaveItem(chat);
				RunOnUiThread(() => chatsAdapter.NotifyDataSetChanged());
				RunOnUiThread( () => FindViewById<ListView>(Resource.Id.chatsListView).SmoothScrollToPosition(chatsAdapter.GetCount() - 1));

				var push = new ParsePush();
				push.Channels = new List<string> {chatroom.webID};
				push.Alert = "Your men might be requesting help!";
				await push.SendAsync();
			};

			Task getUpdatedInfo = new Task (async () => {
				await SynchronizeWithParse ();
			});

			ParsePush.ParsePushNotificationReceived += async (sender, args) => {
				Console.WriteLine("push");
				await SynchronizeWithParse();
			};

			getUpdatedInfo.Start ();
		}
Пример #21
0
        private void registerEvent()
        {
            var nameHelper = new AssemblyName(Assembly.GetExecutingAssembly().FullName);

            hasRegisteredEvent = true;
            ParsePush.ToastNotificationReceived += (sender, args) =>
            {
                var    json = ParsePush.PushJson(args);
                object alertMessage;
                if (json.TryGetValue("alert", out alertMessage))
                {
                    // Display a dialog of all the fields in the toast.
                    Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show(alertMessage.ToString(), GetAppName(), MessageBoxButton.OK));
                }
            };
        }
Пример #22
0
        public Task TestSendPush()
        {
            MutablePushState state = new MutablePushState
            {
                Query = ParseInstallation.Query
            };

            ParsePush thePush = new ParsePush();

            ParsePushPlugins.Instance = new ParsePushPlugins
            {
                PushController = GetMockedPushController(state)
            };

            thePush.Alert = "Alert";
            state.Alert   = "Alert";

            return(thePush.SendAsync().ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);

                thePush.Channels = new List <string> {
                    { "channel" }
                };
                state.Channels = new List <string> {
                    { "channel" }
                };

                return thePush.SendAsync();
            }).Unwrap().ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);

                ParseQuery <ParseInstallation> query = new ParseQuery <ParseInstallation>("aClass");
                thePush.Query = query;
                state.Query = query;

                return thePush.SendAsync();
            }).Unwrap().ContinueWith(t =>
            {
                Assert.IsTrue(t.IsCompleted);
                Assert.IsFalse(t.IsFaulted);
            }));
        }
Пример #23
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            ParseClient.Initialize("4AbWipQ8dD4jpMF0yUYqANh33EuWtfeI44Jf4WIz", "arxKXH5YQ1b0SQVOP953N2G46THVdfwpb7rgxf8c");

            this.Startup += async(sender, args) =>
            {
                // This optional line tracks statistics around app opens, including push effectiveness:
                ParseAnalytics.TrackAppOpens(RootFrame);

                // By convention, the empty string is considered a "Broadcast" channel
                // Note that we had to add "async" to the definition to use the await keyword
                await ParsePush.SubscribeAsync("myTesthannel");
            };

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
Пример #24
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Contacts);
            Button searchContactsBtn = FindViewById <Button> (Resource.Id.search_contacts);

            searchContactsBtn.Click += async(sender, e) => {
                GetParseUsers();
                contactsAdapter = new ContactsAdapter(this);
                var contactsListView = FindViewById <ListView> (Resource.Id.contactsListView);
                contactsListView.Adapter    = contactsAdapter;
                contactsListView.ItemClick += async(object sender2, AdapterView.ItemClickEventArgs e2) => {
                    User curritem = contactsAdapter.GetUserAt(e2.Position);
                    ParseChatRoomDatabase pcrd = new ParseChatRoomDatabase();
                    ChatRoom newchatroom       = new ChatRoom();
                    await pcrd.SaveChatRoomAsync(newchatroom);

                    DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoom(newchatroom);
                    List <User> chatroomUsers = new List <User>();
                    chatroomUsers.Add(curritem);
                    chatroomUsers.Add(DatabaseAccessors.CurrentUser());
                    DatabaseAccessors.ChatRoomDatabaseAccessor.SaveChatRoomUsers(chatroomUsers, newchatroom);
                    var crus = DatabaseAccessors.ChatRoomDatabaseAccessor.GetChatRoomUsers(newchatroom.webID);
                    foreach (ChatRoomUser cru in crus)
                    {
                        await pcrd.SaveChatRoomUsersAsync(cru);

                        var push = new ParsePush();
                        push.Channels = new List <string> {
                            cru.userID
                        };
                        push.Alert = "Your men might be requesting help!";
                        await push.SendAsync();
                    }
                    ChatsActivity.NotifyChatRoomsUpdate();

                    var intent = new Intent(this, typeof(ChatRoomActivity));
                    intent.PutExtra("chatroom", newchatroom.webID);
                    StartActivity(intent);

                    this.Finish();
                };
            };
        }
Пример #25
0
        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler)
        {
            if (application.ApplicationState == UIApplicationState.Active)
            {
                // Application in Foregroud, popup message
                if (userInfo.ContainsKey(NSObject.FromObject("aps")))
                {
                    var aps = userInfo["aps"] as NSMutableDictionary;
                    if (aps != null)
                    {
                        if (aps.ContainsKey(NSObject.FromObject("alert")))
                        {
                            var alert = (aps["alert"] ?? NSObject.FromObject("")).ToString();
                            new UIAlertView("Artportalen", alert, null, "Ok", null).Show();
                        }
                    }
                }
            }

            ParsePush.HandlePush(userInfo);
            completionHandler(UIBackgroundFetchResult.NoData);
        }
Пример #26
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            var oldDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("PushDeviceToken");

            //There's probably a better way to do this
            var strFormat      = new NSString("%@");
            var dt             = new NSString(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr(new MonoTouch.ObjCRuntime.Class("NSString").Handle, new MonoTouch.ObjCRuntime.Selector("stringWithFormat:").Handle, strFormat.Handle, deviceToken.Handle));
            var newDeviceToken = dt.ToString().Replace("<", "").Replace(">", "").Replace(" ", "");

            if (string.IsNullOrEmpty(oldDeviceToken) || !deviceToken.Equals(newDeviceToken))
            {
                //TODO: Put your own logic here to notify your server that the device token has changed/been created!
            }

            //Save device token now
            NSUserDefaults.StandardUserDefaults.SetString(newDeviceToken, "PushDeviceToken");

            //var wc = new WebClient();
            //registrationId="199";

            //userLogin u = controllerUserLogin.getuserLogin();

            /*
             * string myParameters = "iddev="+newDeviceToken+"&uname=iphone5Hipolyto&iduser=1024";
             * wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
             *
             * var result = wc.UploadString("http://www.letsolutions.com.mx/pushTestSpotlight/submit.aspx", "POST",myParameters);
             */
            // ParseLib.ParsePush..StoreDeviceToken (deviceToken);

            Console.WriteLine("Device Token: " + newDeviceToken);

            ParsePush.StoreDeviceToken(deviceToken);
            ParsePush.SubscribeToChannelAsync("events");


            // vtmService.registerDevice(newDeviceToken,int.Parse(u.userId));
        }
Пример #27
0
        private void SendPush(object sender, RoutedEventArgs e)
        {
            var alert = txtAlert.Text;
            var title = txtTitle.Text;

            if (title.Length == 0)
            {
                txtStatus.Text += "\nSending push to everyone with alert: " + alert;
                ParsePush.SendAlertAsync(alert, from installation in ParseInstallation.Query
                                         where installation.DeviceType == "winrt"
                                         select installation);
                ParsePush.SendAlertAsync(alert);
            }
            else
            {
                txtStatus.Text += "\nSending push to everyone with title: " + title + ", alert: " + alert;
                ParsePush.SendDataAsync(new Dictionary <string, object> {
                    { "title", title },
                    { "alert", alert }
                }, from installation in ParseInstallation.Query
                                        where installation.DeviceType == "winrt"
                                        select installation);
            }
        }
Пример #28
0
 /// <summary>
 /// Unsubscribe to the given channels
 /// </summary>
 /// <param name="channel"></param>
 /// <returns></returns>
 public static async Task UnsubscribeAsync(IEnumerable <string> channels)
 {
     await ParsePush.UnsubscribeAsync(channels);
 }
Пример #29
0
 /// <summary>
 /// Unsubscribe to a channel
 /// </summary>
 /// <param name="channel"></param>
 /// <returns></returns>
 public static async Task UnsubscribeAsync(string channel = "")
 {
     await ParsePush.UnsubscribeAsync(channel);
 }
Пример #30
0
        public async void entered(int x, int y)
        {
            //With some analysis we came up with this padding

            //x = x - 180;
            //y = y - 350;
            x = x - 175;
            y = y - 300;

            if (init_x <= x && x <= out_x && init_y <= y && y <= out_y)
            {
                //Debug.WriteLine("Init_X " + init_x + "  Init_Y " + init_y);
                //Debug.WriteLine("OUT_X " + out_x + "  OUT_Y " + out_y);
                //Debug.WriteLine("X  " + x + "     Y= " + y);
                //Debug.WriteLine("WOWOWOW ::::: we are in the regoin " + this.name);

                if (entered_button == false && exited_button == true)
                {
                    //counter = 6;
                    //Abhi - Testing if CountDown Testing Works
                    if (ApplicationData.Current.RoamingSettings.Values.ContainsKey("CountDown"))
                    {
                        counter = (int)ApplicationData.Current.RoamingSettings.Values["CountDown"];
                        counter++;
                    }
                    else
                    {
                        counter = 6;
                    }

                    running_counter = 0;
                    entered_button  = true;
                    hover_button    = true;
                    exited_button   = false;
                }

                else if (entered_button == true && hover_button == true)
                {
                    running_counter++;
                    if (running_counter == internal_counter)
                    {
                        running_counter = 0;
                        counter--;
                        String location = "ms-appx:///Assets/" + counter + ".png";
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                      () =>
                        {
                            this.button.Background = new ImageBrush {
                                ImageSource = new BitmapImage(new Uri(location))
                            };
                        });
                    }


                    entered_button = true;
                    hover_button   = true;
                    exited_button  = false;

                    if (counter == 1)
                    {
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                      () =>
                        {
                            this.button.Background = new ImageBrush {
                                ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Sent.png"))
                            };

                            if (this.button.Name == "b4")
                            {
                                this.button.Background = new ImageBrush {
                                    ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Like.png"))
                                };
                            }

                            if (this.button.Name == "b5")
                            {
                                this.button.Background = new ImageBrush {
                                    ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Dislike.png"))
                                };
                            }

                            if (ApplicationData.Current.RoamingSettings.Values.ContainsKey("UserName"))
                            {
                                userName = (String)ApplicationData.Current.RoamingSettings.Values["UserName"];
                            }
                            else
                            {
                                userName = "******";
                            }

                            if (hover_button == true)
                            {
                                String message = this.content;
                                ParsePush push = new ParsePush();
                                push.Channels  = new List <String> {
                                    "global"
                                };
                                IDictionary <string, object> dic = new Dictionary <string, object>();

                                //Abhishek: Changes for Hard Notification
                                if (name.Equals("b1"))
                                {
                                    dic.Add("sound", "emergency.caf");
                                }
                                else
                                {
                                    dic.Add("sound", ".");
                                }
                                dic.Add("alert", userName + ": " + message);
                                push.Data = dic;
                                push.SendAsync();


                                ParseObject internal_tweets = new ParseObject("TweetsInternal");
                                internal_tweets["content"]  = message;
                                internal_tweets["sender"]   = userName;
                                internal_tweets.SaveAsync();
                            }
                        });

                        hover_button = false;
                    }
                }
            }
            else
            {
                if (entered_button == true && exited_button == false)
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                                  () =>
                    {
                        this.button.Background = null;
                    });

                    exited_button  = true;
                    hover_button   = false;
                    entered_button = false;
                }
            }
        }