Beispiel #1
0
 static void NotifyTrackerAdded(TrackerData t)
 {
     var not = new GcmNotification ();
     not.RegistrationIds.Add (t.UserRegistrationId);
     StringBuilder sb = new StringBuilder ();
     sb.Append ("{event:\"TrackerAdded\", shareId:\"").Append (t.SharePrivateId).Append ("\", trackerId:\"").Append (t.TrackerId).Append ("\"}");
     not.JsonData = sb.ToString ();
     LogService.Log ("Sending message: " + sb.ToString ());
     pushService.QueueNotification (not);
 }
Beispiel #2
0
        public static TrackedShare RegisterTracker(string publicShareId, UserInfo trackerInfo)
        {
            try {
                var db = GetConnection ();

                var s = db.SelectObjectWhere<LocationShareData> ("publicId = {0}", publicShareId);
                if (s == null)
                    return null;

                var t = new TrackerData () {
                    TrackerId = GenerateRandomId (),
                    SharePrivateId = s.PrivateId,
                    UserId = trackerInfo.Id,
                    UserRegistrationId = trackerInfo.RegistrationId,
                    UserName = trackerInfo.Name,
                    UserIcon = trackerInfo.Icon
                };
                db.InsertObject (t);

                LogService.Log ("Registered Tracker " + trackerInfo.Id + " for Target " + publicShareId + ", registration id " + trackerInfo.RegistrationId);
                NotifyTrackerAdded (t);
                return new TrackedShare (s, t.TrackerId);
            } catch (Exception ex) {
                ThrowFailure (ex);
                throw;
            }
        }