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> /// This method adds event listeners to track app opens from tiles, the app list, /// and push notifications. Windows Phone 8 developers should use TrackAppOpens instead of /// TrackAppOpenedAsync, which this method will call automatically. /// /// This method can be called in Application_Launching or as follows in the Application constructor: /// /// <code> /// this.Startup += (sender, args) => { /// ParseAnalytics.TrackAppOpens(RootFrame); /// }; /// </code> /// </summary> /// <param name="frame">The RootFrame of the Application.</param> public static void TrackAppOpens(PhoneApplicationFrame frame) { // This method is supposed to be called from OnLaunched. This call may also be // an app open; if it doesn't contain a valid push hash, make sure that it's counted once upon startup. var isFirstLaunch = true; frame.Navigated += async(sender, args) => { bool alwaysReport = isFirstLaunch; isFirstLaunch = false; // If the user navigates to a push, goes to a new activity, and then goes back, // we shouldn't double count the push. if (args.NavigationMode != System.Windows.Navigation.NavigationMode.New) { return; } var json = ParsePush.PushJson(args.Uri.ToString()); object alert = null; if (json.TryGetValue("alert", out alert) || alwaysReport) { string pushHash = ParseAnalyticsUtilities.MD5DigestFromPushPayload(alert); await TrackAppOpenedWithPushHashAsync(pushHash); } }; }
/// <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. 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 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 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 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()); }
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 (); }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return(((Task)null).Safe()); } object pushHash; IDictionary <string, object> contentJson = ParsePush.PushJson(launchArgs); contentJson.TryGetValue("push_hash", out pushHash); return(ParseAnalytics.TrackAppOpenedWithPushHashAsync((string)pushHash)); }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return(((Task)null).Safe()); } IDictionary <string, object> contentJson = ParsePush.PushJson(launchArgs); object alert; string pushHash = null; if (contentJson.TryGetValue("alert", out alert)) { pushHash = ParseAnalyticsUtilities.MD5DigestFromPushPayload(alert); } return(ParseAnalytics.TrackAppOpenedWithPushHashAsync(pushHash)); }
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(); }; }; }
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; }
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(); }
/// <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. 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 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 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 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 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 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(); }
/// <summary> /// Handle push intent from <see cref="ParsePushBroadcastReceiver"/>. /// </summary> /// <param name="intent">The intent to be handled.</param> protected override void OnHandleIntent(Intent intent) { Task task = Task.FromResult(0); try { // Assume only GCM intent is received here. switch (intent.Action) { case ParsePushBroadcastReceiver.ActionGcmRegisterResponse: task = GcmRegistrar.GetInstance().HandleRegistrationIntentAsync(intent); break; case ParsePushBroadcastReceiver.ActionGcmReceive: if (ManifestInfo.HasPermissionForGCM()) { ParsePush.parsePushNotificationReceived.Invoke(ParseInstallation.CurrentInstallation, new ParsePushNotificationEventArgs(ParsePush.PushJson(intent))); } break; default: // TODO (hallucinogen): Prints error that we don't support other intent. break; } // Wait for its completion with timeout. task.Wait(IntentServiceHandlerTimeout); } finally { ParseWakefulHelper.CompleteWakefulIntent(intent); } }