public Task TestSendPush() { MutablePushState state = new MutablePushState { Query = ParseInstallation.Query }; ParsePush thePush = new ParsePush(); ParseCorePlugins.Instance.PushController = GetMockedPushController(state); thePush.Alert = "Alert"; state.Alert = "Alert"; return thePush.SendAsync().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); thePush.Channels = new List<string> { { "channel" } }; state.Channels = new List<string> { { "channel" } }; return thePush.SendAsync(); }).Unwrap().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); ParseQuery<ParseInstallation> query = new ParseQuery<ParseInstallation>("aClass"); thePush.Query = query; state.Query = query; return thePush.SendAsync(); }).Unwrap().ContinueWith(t => { Assert.True(t.IsCompleted); Assert.False(t.IsFaulted); ParseCorePlugins.Instance.PushController = null; }); }
/// <summary> /// Pushes a simple message to every device. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> public static Task SendAlertAsync(string alert) { var push = new ParsePush(); push.Alert = alert; return(push.SendAsync()); }
/// <summary> /// Pushes an arbitrary payload to every device. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> public static Task SendDataAsync(IDictionary <string, object> data) { var push = new ParsePush(); push.Data = data; return(push.SendAsync()); }
/// <summary> /// Pushes a simple message to every device subscribed to any of channels. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = channels; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="channels">An Installation must be subscribed to any of channels to receive this Push Notification.</param> public static Task SendAlertAsync(string alert, IEnumerable <string> channels) { var push = new ParsePush(); push.Channels = channels; push.Alert = alert; return(push.SendAsync()); }
/// <summary> /// Pushes a simple message to every device matching the target query. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Query = query; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="query">A query filtering the devices which should receive this Push Notification.</param> public static Task SendAlertAsync(string alert, ParseQuery <ParseInstallation> query) { var push = new ParsePush(); push.Query = query; push.Alert = alert; return(push.SendAsync()); }
/// <summary> /// Pushes an arbitrary payload to every device subscribed to any of channels. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = channels; /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="channels">An Installation must be subscribed to any of channels to receive this Push Notification.</param> public static Task SendDataAsync(IDictionary <string, object> data, IEnumerable <string> channels) { var push = new ParsePush(); push.Channels = channels; push.Data = data; return(push.SendAsync()); }
/// <summary> /// Pushes an arbitrary payload to every device matching target. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Query = query /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="query">A query filtering the devices which should receive this Push Notification.</param> public static Task SendDataAsync(IDictionary <string, object> data, ParseQuery <ParseInstallation> query) { var push = new ParsePush(); push.Query = query; push.Data = data; return(push.SendAsync()); }
async void sendPush(object sender, EventArgs e) { var push = new ParsePush(); push.Query = from installation in ParseInstallation.Query where installation.Get<String>("numeroDonante") == tbDestino.Text select installation; push.Alert = tbMsg.Text; await push.SendAsync(); }
/// <summary> /// Pushes an arbitrary payload to every device subscribed to channel. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = new List<string> { channel }; /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="channel">An Installation must be subscribed to channel to receive this Push Notification.</param> public static Task SendDataAsync(IDictionary <string, object> data, string channel) { var push = new ParsePush(); push.Channels = new List <string> { channel }; push.Data = data; return(push.SendAsync()); }
/// <summary> /// Pushes a simple message to every device subscribed to channel. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = new List<string> { channel }; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="channel">An Installation must be subscribed to channel to receive this Push Notification.</param> public static Task SendAlertAsync(string alert, string channel) { var push = new ParsePush(); push.Channels = new List <string> { channel }; push.Alert = alert; return(push.SendAsync()); }
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 (); }
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(); }; }; }
/// <summary> /// Pushes an arbitrary payload to every device matching target. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Query = query /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="query">A query filtering the devices which should receive this Push Notification.</param> public static Task SendDataAsync(IDictionary<string, object> data, ParseQuery<ParseInstallation> query) { var push = new ParsePush(); push.Query = query; push.Data = data; return push.SendAsync(); }
/// <summary> /// Pushes a simple message to every device. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> public static Task SendAlertAsync(string alert) { var push = new ParsePush(); push.Alert = alert; return push.SendAsync(); }
/// <summary> /// Pushes a simple message to every device subscribed to channel. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = new List<string> { channel }; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="channel">An Installation must be subscribed to channel to receive this Push Notification.</param> public static Task SendAlertAsync(string alert, string channel) { var push = new ParsePush(); push.Channels = new List<string> { channel }; push.Alert = alert; return push.SendAsync(); }
/// <summary> /// Pushes a simple message to every device subscribed to any of channels. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = channels; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="channels">An Installation must be subscribed to any of channels to receive this Push Notification.</param> public static Task SendAlertAsync(string alert, IEnumerable<string> channels) { var push = new ParsePush(); push.Channels = channels; push.Alert = alert; return push.SendAsync(); }
/// <summary> /// Pushes a simple message to every device matching the target query. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Query = query; /// push.Data = new Dictionary<string, object>{{"alert", alert}}; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="alert">The alert message to send.</param> /// <param name="query">A query filtering the devices which should receive this Push Notification.</param> public static Task SendAlertAsync(string alert, ParseQuery<ParseInstallation> query) { var push = new ParsePush(); push.Query = query; push.Alert = alert; return push.SendAsync(); }
/// <summary> /// Pushes an arbitrary payload to every device. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> public static Task SendDataAsync(IDictionary<string, object> data) { var push = new ParsePush(); push.Data = data; return push.SendAsync(); }
/// <summary> /// Pushes an arbitrary payload to every device subscribed to any of channels. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = channels; /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="channels">An Installation must be subscribed to any of channels to receive this Push Notification.</param> public static Task SendDataAsync(IDictionary<string, object> data, IEnumerable<string> channels) { var push = new ParsePush(); push.Channels = channels; push.Data = data; return push.SendAsync(); }
/// <summary> /// Pushes an arbitrary payload to every device subscribed to channel. This is shorthand for: /// /// <code> /// var push = new ParsePush(); /// push.Channels = new List<string> { channel }; /// push.Data = data; /// return push.SendAsync(); /// </code> /// </summary> /// <param name="data">A push payload. See the ParsePush.Data property for more information.</param> /// <param name="channel">An Installation must be subscribed to channel to receive this Push Notification.</param> public static Task SendDataAsync(IDictionary<string, object> data, string channel) { var push = new ParsePush(); push.Channels = new List<string> { channel }; push.Data = data; return push.SendAsync(); }
private async void SendPush() { // Send a notification to all devices subscribed to the "Giants" channel. var push = new ParsePush(); push.Channels = new List<string> { "SpotterRequest" }; push.Alert = "Spotter has been requested!"; await push.SendAsync(); }
public async Task<RepositoryResponse<Notification>> AddNotification(Notification notification) { var response = new RepositoryResponse<Notification> { }; try { var Noti = Parse.ParseObject.Create("Notification"); #region Add Dependency Relationship DependencyRepository DependencyContext = new DependencyRepository(); RepositoryResponse<ParseObject> Dependency = await DependencyContext.GetDependencyById(notification.ID_DEPENDENCY); ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Dependency"); IEnumerable<ParseObject> result = await query.FindAsync(); #endregion #region Add City Relationship CityRepository CityContext = new CityRepository(); RepositoryResponse<ParseObject> City = await CityContext.GetCityById(notification.ID_CITY); query = new ParseQuery<ParseObject>("City"); result = await query.FindAsync(); #endregion var relation = Noti.GetRelation<ParseObject>("ID_Dependency"); relation.Add(Dependency.Data); relation = Noti.GetRelation<ParseObject>("ID_City"); relation.Add(City.Data); var message = string.Format("{0} > {1}: {2}", Dependency.Data["Name"].ToString(), City.Data["Name"].ToString(), notification.NOTIFICATION_TEXT); Noti.Add("NotificationText", message); await Noti.SaveAsync(); await Noti.SaveAsync(); var push = new ParsePush(); push.Query = from installation in ParseInstallation.Query where installation.Get<string>("City").Contains(notification.ID_CITY) select installation; push.Alert = message; await push.SendAsync(); notification.ID = Noti.ObjectId; response.Data = notification; response.Success = true; } catch (Exception ex) { response.Success = false; response.Error = ex; } return response; }