Esempio n. 1
0
            public AppSettings(string appId, string appKey, BuddyOptions options)
            {
                AppID   = appId;
                AppKey  = appKey;
                Options = options;

                if (appId != null)
                {
                    Load();
                }
            }
Esempio n. 2
0
        public BuddyClient(string appid, string appkey, BuddyOptions options = null)
        {
            if (String.IsNullOrEmpty(appid))
            {
                throw new ArgumentException("Can't be null or empty.", "appId");
            }
            if (String.IsNullOrEmpty(appkey))
            {
                throw new ArgumentException("Can't be null or empty.", "AppKey");
            }
            if (options == null)
            {
                options = new BuddyOptions();
            }

            sharedSecret         = options.SharedSecret;
            options.SharedSecret = null;

            if (!PlatformAccess.Current.SupportsFlags(options.Flags))
            {
                throw new ArgumentException("Invalid flags for this client type.");
            }

            this.AppId  = appid.Trim();
            this.AppKey = appkey.Trim();

            this.Options = options;

            _appSettings = new AppSettings(appid, appkey, options);

            UpdateAccessLevel();

            if (options.Flags.HasFlag(BuddyClientFlags.AutoCrashReport))
            {
                InitCrashReporting();
            }

            PlatformAccess.Current.SetPushToken(_appSettings.DevicePushToken);
            PlatformAccess.Current.PushTokenChanged += this.PushTokenChanged;

            PlatformAccess.Current.NotificationReceived += (s, na) => {
                string id = na.ID;
                if (_appSettings.DeviceToken != null)
                {
                    PostAsync <bool>(
                        "/notifications/received/" + id,
                        null);
                }
            };
        }
Esempio n. 3
0
        public static IBuddyClient Init(string appId, string appKey, BuddyOptions options = null)
        {
            if (options == null)
            {
                options = new BuddyOptions();
            }

            if (_currentClientKey != null && !options.Flags.HasFlag(BuddyClientFlags.AllowReinitialize))
            {
                throw new InvalidOperationException("Already initialized.");
            }

            CurrentInstance = new BuddyClient(appId, appKey, options);

            return(CurrentInstance);
        }
Esempio n. 4
0
 public BuddyCreds(string appId, string appKey, BuddyOptions options)
 {
     AppID   = appId;
     AppKey  = appKey;
     Options = options;
 }