Exemple #1
0
        static public void HandleStartPush(string arguments)
        {
            if (arguments != null && arguments.Length != 0)
            {
                try
                {
                    //Sample to handle push custom data on start
                    ToastPush push = SDKHelpers.ParsePushData(arguments);
                    if (push != null)
                    {
                        push.OnStart = true;
                        NotificationService.StartPush = push;

                        NotificationService service = NotificationService.GetCurrent(null);
                        if (service != null)
                        {
                            StatisticRequest request = new StatisticRequest {
                                AppId = service.AppID, Hash = push.Hash
                            };
                            PushwooshAPIServiceBase.InternalSendRequestAsync(request, null, null);
                        }
                    }
                }
                catch { }
            }
        }
Exemple #2
0
        private void SubscribeToPushwoosh(string appID)
        {
            string token = _notificationChannel.Uri.ToString();
            RegistrationRequest request = new RegistrationRequest {
                AppId = appID, PushToken = token
            };

            PushwooshAPIServiceBase.InternalSendRequestAsync(request, SendTokenToPushwooshSuccess, SendTokenToPushwooshFailed);
        }
Exemple #3
0
        public void TrackInAppPurchase(string productId, double price, string currency)
        {
            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            SendPurchaseRequest request = new SendPurchaseRequest {
                AppId = AppID, ProductIdentifier = productId, Currency = currency, Price = price, Quantity = 1, DateTimeStamp = unixTimestamp
            };

            PushwooshAPIServiceBase.InternalSendRequestAsync(request, null, null);
        }
Exemple #4
0
        public void GetTags(EventHandler <string> OnTagsSuccess, EventHandler <string> OnError)
        {
            GetTagsRequest request = new GetTagsRequest {
                AppId = AppID
            };

            PushwooshAPIServiceBase.InternalSendRequestAsync(request, (obj, arg) => { if (OnTagsSuccess != null)
                                                                                      {
                                                                                          OnTagsSuccess(this, request.Tags.ToString());
                                                                                      }
                                                             }, OnError);
        }
Exemple #5
0
        public void SendTag(IList <KeyValuePair <string, object> > tagList, EventHandler <string> OnTagSendSuccess, EventHandler <string> OnError)
        {
            SetTagsRequest request = new SetTagsRequest {
                AppId = AppID
            };

            request.BuildTags(tagList);
            PushwooshAPIServiceBase.InternalSendRequestAsync(request, (obj, arg) => { if (OnTagSendSuccess != null)
                                                                                      {
                                                                                          OnTagSendSuccess(this, null);
                                                                                      }
                                                             }, OnError);
        }
Exemple #6
0
        /// <summary>
        ///  send Tag
        /// </summary>
        public void SendTag([ReadOnlyArray()] String[] key, [ReadOnlyArray()]  object[] values, EventHandler <string> OnTagSendSuccess, EventHandler <string> OnError)
        {
            SetTagsRequest request = new SetTagsRequest {
                AppId = AppID
            };

            request.BuildTags(key, values);
            PushwooshAPIServiceBase.InternalSendRequestAsync(request, (obj, arg) => { if (OnTagSendSuccess != null)
                                                                                      {
                                                                                          OnTagSendSuccess(this, null);
                                                                                      }
                                                             }, OnError);
        }
Exemple #7
0
        /// <param name="appID">PushWoosh application id</param>
        private NotificationService(string appID)
        {
            AppID = appID;
            ApplicationData.Current.LocalSettings.Values["com.pushwoosh.appid"] = appID;

            PushToken = "";

            GeoZone = new GeozoneService(appID);

            AppOpenRequest request = new AppOpenRequest {
                AppId = appID
            };

            PushwooshAPIServiceBase.InternalSendRequestAsync(request, null, null);
        }
Exemple #8
0
        /// <summary>
        /// Unsubscribe from pushes at pushwoosh server
        /// </summary>
        public void UnsubscribeFromPushes(EventHandler <string> success, EventHandler <string> failure)
        {
            if (_notificationChannel != null)
            {
                _notificationChannel.Close();
                _notificationChannel = null;
            }

            PushToken = "";
            UnregisterRequest request = new UnregisterRequest {
                AppId = AppID
            };

            PushwooshAPIServiceBase.InternalSendRequestAsync(request, (obj, arg) => { if (success != null)
                                                                                      {
                                                                                          success(this, null);
                                                                                      }
                                                             }, failure);
        }
Exemple #9
0
        private void ChannelShellToastNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            Debug.WriteLine("/********************************************************/");
            Debug.WriteLine("Incoming Notification: " + DateTime.Now.ToString());

            String notificationContent = String.Empty;

            ToastPush push = null;
            String    type = String.Empty;

            switch (e.NotificationType)
            {
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                type = "Badge";
                break;

            case PushNotificationType.Tile:

                notificationContent = e.TileNotification.Content.GetXml();
                type = "Tile";
                break;

            case PushNotificationType.Toast:

                notificationContent = e.ToastNotification.Content.GetXml();

                try
                {
                    IXmlNode node       = e.ToastNotification.Content.DocumentElement.SelectSingleNode("/toast");
                    IXmlNode launchAttr = node.Attributes.GetNamedItem("launch");
                    String   args       = launchAttr.NodeValue.ToString();

                    push = SDKHelpers.ParsePushData(args);

                    //Sample to handle push custom data on start
                    StatisticRequest request2 = new StatisticRequest {
                        AppId = AppID, Hash = push.Hash
                    };
                    PushwooshAPIServiceBase.InternalSendRequestAsync(request2, null, null);
                }
                catch { }

                type = "Toast";
                break;

            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                type = "Raw";
                break;
            }

            if (push == null)
            {
                StatisticRequest request2 = new StatisticRequest {
                    AppId = AppID
                };
                PushwooshAPIServiceBase.InternalSendRequestAsync(request2, null, null);
            }

            Debug.WriteLine("Received {0} notification", type);
            Debug.WriteLine("Notification content: " + notificationContent);

            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                try
                {
                    if (push != null)
                    {
                        FireAcceptedPush(push);
                    }
                }
                catch (Exception)
                {
                    //Noting todo here
                }
            });
        }