コード例 #1
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes an arbitrary payload to every device. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Data = data;
        /// return push.SendAsync();
        /// </code>
        /// </summary>
        /// <param name="data">A push payload. See the AVPush.Data property for more information.</param>
        public static Task SendDataAsync(IDictionary <string, object> data)
        {
            var push = new AVPush();

            push.Data = data;
            return(push.SendAsync());
        }
コード例 #2
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes a simple message to every device. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();

            push.Alert = alert;
            return(push.SendAsync());
        }
コード例 #3
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes a simple message to every device subscribed to any of channels. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Channels = channels;
        /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();

            push.Channels = channels;
            push.Alert    = alert;
            return(push.SendAsync());
        }
コード例 #4
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes a simple message to every device matching the target query. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Query = query;
        /// push.Data = new Dictionary&lt;string, object&gt;{{"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, AVQuery <AVInstallation> query)
        {
            var push = new AVPush();

            push.Query = query;
            push.Alert = alert;
            return(push.SendAsync());
        }
コード例 #5
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes an arbitrary payload to every device subscribed to any of channels. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Channels = channels;
        /// push.Data = data;
        /// return push.SendAsync();
        /// </code>
        /// </summary>
        /// <param name="data">A push payload. See the AVPush.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 AVPush();

            push.Channels = channels;
            push.Data     = data;
            return(push.SendAsync());
        }
コード例 #6
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes an arbitrary payload to every device matching target. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Query = query
        /// push.Data = data;
        /// return push.SendAsync();
        /// </code>
        /// </summary>
        /// <param name="data">A push payload. See the AVPush.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, AVQuery <AVInstallation> query)
        {
            var push = new AVPush();

            push.Query = query;
            push.Data  = data;
            return(push.SendAsync());
        }
コード例 #7
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes a simple message to every device subscribed to channel. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Channels = new List&lt;string&gt; { channel };
        /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();

            push.Channels = new List <string> {
                channel
            };
            push.Alert = alert;
            return(push.SendAsync());
        }
コード例 #8
0
ファイル: ParsePush.cs プロジェクト: longyunzhou/NFC
        /// <summary>
        /// Pushes an arbitrary payload to every device subscribed to channel. This is shorthand for:
        ///
        /// <code>
        /// var push = new AVPush();
        /// push.Channels = new List&lt;string&gt; { channel };
        /// push.Data = data;
        /// return push.SendAsync();
        /// </code>
        /// </summary>
        /// <param name="data">A push payload. See the AVPush.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 AVPush();

            push.Channels = new List <string> {
                channel
            };
            push.Data = data;
            return(push.SendAsync());
        }
コード例 #9
0
        /// <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 = AVPush.PushJson(launchArgs);

            contentJson.TryGetValue("push_hash", out pushHash);
            return(AVAnalytics.TrackAppOpenedWithPushHashAsync((string)pushHash));
        }
コード例 #10
0
        public Task TestSendPush()
        {
            MutableAVState state = new MutableAVState {
            Query = AVInstallation.Query
              };

              AVPush thePush = new AVPush();
              AVPushPlugins.Instance = new AVPushPlugins {
            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);

            AVQuery<AVInstallation> query = new AVQuery<AVInstallation>("aClass");
            thePush.Query = query;
            state.Query = query;

            return thePush.SendAsync();
              }).Unwrap().ContinueWith(t => {
            Assert.True(t.IsCompleted);
            Assert.False(t.IsFaulted);
              });
        }
コード例 #11
0
        /// <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) => {
        ///   AVAnalytics.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 = AVPush.PushJson(args.Uri.ToString());
                object hash = null;
                if (json.TryGetValue("push_hash", out hash) || alwaysReport)
                {
                    await TrackAppOpenedWithPushHashAsync((string)hash);
                }
            };
        }
コード例 #12
0
 /// <summary>
 /// Pushes a simple message to every device subscribed to channel. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Channels = new List&lt;string&gt; { channel };
 /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();
       push.Channels = new List<string> { channel };
       push.Alert = alert;
       return push.SendAsync();
 }
コード例 #13
0
        /// <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())
                    {
                        AVPush.parsePushNotificationReceived.Invoke(AVInstallation.CurrentInstallation, new AVPushNotificationEventArgs(AVPush.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 {
                AVWakefulHelper.CompleteWakefulIntent(intent);
            }
        }
コード例 #14
0
 /// <summary>
 /// Pushes a simple message to every device matching the target query. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Query = query;
 /// push.Data = new Dictionary&lt;string, object&gt;{{"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, AVQuery<AVInstallation> query)
 {
     var push = new AVPush();
       push.Query = query;
       push.Alert = alert;
       return push.SendAsync();
 }
コード例 #15
0
 /// <summary>
 /// Pushes a simple message to every device subscribed to any of channels. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Channels = channels;
 /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();
       push.Channels = channels;
       push.Alert = alert;
       return push.SendAsync();
 }
コード例 #16
0
 /// <summary>
 /// Pushes an arbitrary payload to every device. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the AVPush.Data property for more information.</param>
 public static Task SendDataAsync(IDictionary<string, object> data)
 {
     var push = new AVPush();
       push.Data = data;
       return push.SendAsync();
 }
コード例 #17
0
 /// <summary>
 /// Pushes an arbitrary payload to every device subscribed to channel. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Channels = new List&lt;string&gt; { channel };
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the AVPush.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 AVPush();
       push.Channels = new List<string> { channel };
       push.Data = data;
       return push.SendAsync();
 }
コード例 #18
0
 /// <summary>
 /// Pushes an arbitrary payload to every device subscribed to any of channels. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Channels = channels;
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the AVPush.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 AVPush();
       push.Channels = channels;
       push.Data = data;
       return push.SendAsync();
 }
コード例 #19
0
 /// <summary>
 /// Pushes an arbitrary payload to every device matching target. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Query = query
 /// push.Data = data;
 /// return push.SendAsync();
 /// </code>
 /// </summary>
 /// <param name="data">A push payload. See the AVPush.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, AVQuery<AVInstallation> query)
 {
     var push = new AVPush();
       push.Query = query;
       push.Data = data;
       return push.SendAsync();
 }
コード例 #20
0
 /// <summary>
 /// Pushes a simple message to every device. This is shorthand for:
 ///
 /// <code>
 /// var push = new AVPush();
 /// push.Data = new Dictionary&lt;string, object&gt;{{"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 AVPush();
       push.Alert = alert;
       return push.SendAsync();
 }