public Task TestSubscribe() { List <string> channels = new List <string>(); ParseCorePlugins.Instance.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); ParseCorePlugins.Instance.PushChannelsController = null; })); }
public void subscribe(string args) { var topic = JSON.JsonHelper.Deserialize <string[]>(args)[0].ToString(); ParsePush.SubscribeAsync(topic); DispatchCommandResult(new PluginResult(PluginResult.Status.OK, true)); }
public async Task RegisterForPush(IActivatedEventArgs args) { await ParsePush.SubscribeAsync(""); await ParseInstallation.CurrentInstallation.SaveAsync(); await ParseAnalytics.TrackAppOpenedAsync(args as LaunchActivatedEventArgs); }
private async void Subscribe() { try { await ParsePush.SubscribeAsync("global"); } catch (Exception x) { // log } }
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"); }
private async void SubscribeForPush() { try { await ParsePush.SubscribeAsync(""); } catch (Exception x) { // TODO: Log this! } }
private async void Subscribe() { try { await ParsePush.SubscribeAsync("global"); } catch (Exception x) { Debug.WriteLine(x); } }
/* private void _registerAsPushNotificationClient() { ParseClient.Initialize(appId, clientKey); await ParseInstallation.CurrentInstallation.SaveAsync(); //String installationId = ParseInstallation.CurrentInstallation.InstallationId.ToString(); //String objectId = ParseInstallation.CurrentInstallation.ObjectId.ToString(); //var installation = ParseInstallation.CurrentInstallation; //IEnumerable<string> subscribedChannels = installation.Channels; PluginResult pr = new PluginResult(PluginResult.Status.OK, "onRegisterAsPushNotificationClientSucceeded"); pr.KeepCallback = true; DispatchCommandResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.KeepCallback = true; //DispatchCommandResult(pr); } private void _unregister() { PluginResult pr = new PluginResult(PluginResult.Status.OK, "onUnregisterSucceeded"); pr.KeepCallback = true; DispatchCommandResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.KeepCallback = true; //DispatchCommandResult(pr); } */ private async void _subscribeToChannel(string channel) { ParsePush.SubscribeAsync(channel); PluginResult pr = new PluginResult(PluginResult.Status.OK, "onSubscribeToChannelSucceeded"); pr.KeepCallback = true; DispatchCommandResult(pr); //PluginResult pr = new PluginResult(PluginResult.Status.ERROR); //pr.KeepCallback = true; //DispatchCommandResult(pr); }
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, "")); }
/// <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)); }
/// <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; } }
/// <summary> /// Subscribe to the given channels /// </summary> /// <param name="channel"></param> /// <returns></returns> public static async Task SubscribeAsync(IEnumerable <string> channels) { await ParsePush.SubscribeAsync(channels); }
/// <summary> /// Subscribe to a channel /// </summary> /// <param name="channel"></param> /// <returns></returns> public static async Task SubscribeAsync(string channel = "") { await ParsePush.SubscribeAsync(channel); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { #if WINDOWS_PHONE_APP // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; #endif // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); await ParsePush.SubscribeAsync(""); ParseAnalytics.TrackAppOpenedAsync(e); }