public void Init()
        {
            bool autoPrompt = false, inAppLaunchURL = false;

            if (_builder.IOSSettings != null)
            {
                if (_builder.IOSSettings.ContainsKey(kOSSettingsKeyAutoPrompt))
                {
                    autoPrompt = _builder.IOSSettings[kOSSettingsKeyAutoPrompt];
                }
                if (_builder.IOSSettings.ContainsKey(kOSSettingsKeyInAppLaunchURL))
                {
                    inAppLaunchURL = _builder.IOSSettings[kOSSettingsKeyInAppLaunchURL];
                }
            }

            var convertedLogLevel    = (OneSLogLevel)((ulong)((int)_logLevel));
            var convertedVisualLevel = (OneSLogLevel)((ulong)((int)_visualLogLevel));

            OneSignal.SetLogLevel(convertedLogLevel, convertedVisualLevel);

            var dict = new Foundation.NSDictionary("kOSSettingsKeyInAppLaunchURL"
                                                   , new Foundation.NSNumber(inAppLaunchURL)
                                                   , "kOSSettingsKeyAutoPrompt"
                                                   , new Foundation.NSNumber(autoPrompt)
                                                   , "kOSSettingsKeyInFocusDisplayOption"
                                                   , new Foundation.NSNumber((int)_builder.DisplayOption));

            OneSignal.InitWithLaunchOptions(new Foundation.NSDictionary()
                                            , _builder.AppID
                                            , NotificationReceivedHandler
                                            , NotificationOpenedHandler
                                            , dict);
        }
示例#2
0
        private static CGSize MeasureTextSize1(string text, CoreText.CTFont font)   // this method seems to give the wrong width
        // https://stackoverflow.com/questions/11245526/measuring-the-text-width
        {
            var dict = new Foundation.NSDictionary <Foundation.NSString, CoreText.CTFont> (new Foundation.NSString("font"), font);

            return(new Foundation.NSString(text).StringSize(dict));
        }
示例#3
0
        /// <summary>
        /// Initializes a Manager that stores Databases in the given directory.
        /// </summary>
        /// <param name="directoryFile"><see cref="System.IO.DirectoryInfo"/> object for initializing the Manager object.</param>
        /// <param name="options">Option flags for initialization.</param>
        /// <exception cref="T:System.IO.DirectoryNotFoundException">Thrown when there is an error while accessing or creating the given directory.</exception>
        public Manager(DirectoryInfo directoryFile, ManagerOptions options)
        {
            Log.I(TAG, "Starting Manager version: " + VersionString);

            this.directoryFile = directoryFile;
            this.options       = options ?? DefaultOptions;
            this.databases     = new Dictionary <string, Database>();
            this.replications  = new List <Replication>();

            //create the directory, but don't fail if it already exists
            if (!directoryFile.Exists)
            {
                directoryFile.Create();
                directoryFile.Refresh();
                if (!directoryFile.Exists)
                {
                    throw new  DirectoryNotFoundException("Unable to create directory " + directoryFile);
                }
            }

            UpgradeOldDatabaseFiles(directoryFile);

            #if __IOS__
            Foundation.NSString protection;
            switch (options.FileProtection & Foundation.NSDataWritingOptions.FileProtectionMask)
            {
            case Foundation.NSDataWritingOptions.FileProtectionNone:
                protection = Foundation.NSFileManager.FileProtectionNone;
                break;

            case Foundation.NSDataWritingOptions.FileProtectionComplete:
                protection = Foundation.NSFileManager.FileProtectionComplete;
                break;

            case Foundation.NSDataWritingOptions.FileProtectionCompleteUntilFirstUserAuthentication:
                protection = Foundation.NSFileManager.FileProtectionCompleteUntilFirstUserAuthentication;
                break;

            default:
                protection = Foundation.NSFileManager.FileProtectionCompleteUnlessOpen;
                break;
            }

            var attributes = new Foundation.NSDictionary(Foundation.NSFileManager.FileProtectionKey, protection);
            Foundation.NSError error;
            Foundation.NSFileManager.DefaultManager.SetAttributes(attributes, directoryFile.FullName, out error);
            #endif

            var scheduler = options.CallbackScheduler;
            CapturedContext = new TaskFactory(scheduler);
            workExecutor    = new TaskFactory(new SingleTaskThreadpoolScheduler());
            Log.D(TAG, "New Manager uses a scheduler with a max concurrency level of {0}".Fmt(workExecutor.Scheduler.MaximumConcurrencyLevel));

            this.NetworkReachabilityManager = new NetworkReachabilityManager();

            SharedCookieStore = new CookieStore(this.directoryFile.FullName);
            StorageType       = "SQLite";
            Shared            = new SharedState();
        }
示例#4
0
        public static void Execute(UIKit.UIApplication application, Foundation.NSDictionary launchOptions)
        {
            SetupFlexiMvvm();
            SetupResources();

            var config = CreateBootstrapperConfig(application, launchOptions);

            ExecuteBootstrappers(config);
        }
        private void keyboardWillShow(Foundation.NSNotification aNotification)
        {
            Foundation.NSDictionary info   = aNotification.UserInfo;
            CoreGraphics.CGSize     kbSize = (info.ObjectForKey(UIKeyboard.FrameBeginUserInfoKey) as Foundation.NSValue).RectangleFValue.Size;

            UIEdgeInsets contentInsets = new UIEdgeInsets(this._tableView.ContentInset.Top, 0.0, kbSize.Height, 0);

            this._tableView.ContentInset          = contentInsets;
            this._tableView.ScrollIndicatorInsets = contentInsets;
        }
 public void InitWithLaunchOptions(Foundation.NSDictionary launchOptions)
 {
     if (Release)
     {
         PlotRelease.InitializeWithLaunchOptions(launchOptions, this);
     }
     else
     {
         PlotDebug.InitializeWithLaunchOptions(launchOptions, this);
     }
 }
 public void DidReceiveMessage(WCSession session, Foundation.NSDictionary<Foundation.NSString, Foundation.NSObject> message)
 {
     NSObject state;
     if (message.TryGetValue(new NSString("State"), out state))
     {
         DispatchQueue.MainQueue.DispatchAsync(() =>
         {
             var @string = state as NSString;
             this.UpdateSessionState(@string);
         });
     }
 }
示例#8
0
        public static Dictionary <string, object> NSDictToPureDict(Foundation.NSDictionary nsDict)
        {
            if (nsDict == null)
            {
                return(null);
            }
            Foundation.NSError  error;
            Foundation.NSData   jsonData     = Foundation.NSJsonSerialization.Serialize(nsDict, (Foundation.NSJsonWritingOptions) 0, out error);
            Foundation.NSString jsonNSString = Foundation.NSString.FromData(jsonData, Foundation.NSStringEncoding.UTF8);
            string jsonString = jsonNSString.ToString();

            return(Json.Deserialize(jsonString) as Dictionary <string, object>);
        }
示例#9
0
        public OneSignalIOS(string appId, bool autoPrompt, bool inAppLaunchURLs, OneSignal.OSInFocusDisplayOption displayOption, OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel)
        {
            var convertedLogLevel    = (iOS.OneSLogLevel)((int)logLevel);
            var convertedVisualLevel = (iOS.OneSLogLevel)((int)visualLevel);

            iOS.OneSignal.SetLogLevel(convertedLogLevel, convertedVisualLevel);
            var dict = new Foundation.NSDictionary("kOSSettingsKeyInAppLaunchURL", new Foundation.NSNumber(inAppLaunchURLs),
                                                   "kOSSettingsKeyAutoPrompt", new Foundation.NSNumber(autoPrompt),
                                                   "kOSSettingsKeyInFocusDisplayOption", new Foundation.NSNumber((int)displayOption)
                                                   );

            iOS.OneSignal.InitWithLaunchOptions(new Foundation.NSDictionary(), appId, NotificationReceivedHandler, NotificationOpenedHandler, dict);
        }
示例#10
0
        /// <summary>
        /// Gets the Plot interface.
        /// </summary>
        /// <returns>a link to the Plot interface</returns>
        /// <param name="launchOptions">the launchOptions passed to the delegate</param>
        /// <param name="debug">whether debug logging should be enabled</param>
        public static IPlot GetInstance(Foundation.NSDictionary launchOptions, bool debug)
        {
            PlotImplementation instance = (PlotImplementation)GetInstance();

            instance.Release = !debug;

            if (launchOptions == null)
            {
                launchOptions = new Foundation.NSDictionary();
            }

            Foundation.NSMutableDictionary extendedLaunchOptions = new Foundation.NSMutableDictionary(launchOptions);
            extendedLaunchOptions.Add(new Foundation.NSString("plot-xamarin-version"), new Foundation.NSString(Mono.Runtime.GetDisplayName()));
            instance.InitWithLaunchOptions(extendedLaunchOptions);
            return(instance);
        }
示例#11
0
        private OSNotification OSNotificationToNative(iOS.OSNotification notif)
        {
            var notification = new OSNotification();

            notification.displayType        = (OSNotification.DisplayType)notif.DisplayType;
            notification.shown              = notif.Shown;
            notification.silentNotification = notif.SilentNotification;

            notification.payload = new OSNotificationPayload();


            notification.payload.actionButtons = new List <Dictionary <string, object> >();
            if (notif.Payload.ActionButtons != null)
            {
                for (int i = 0; i < (int)notif.Payload.ActionButtons.Count; ++i)
                {
                    Foundation.NSDictionary element = notif.Payload.ActionButtons.GetItem <Foundation.NSDictionary>((uint)i);
                    notification.payload.actionButtons.Add(NSDictToPureDict(element));
                }
            }

            notification.payload.additionalData = new Dictionary <string, object>();
            if (notif.Payload.AdditionalData != null)
            {
                foreach (KeyValuePair <Foundation.NSObject, Foundation.NSObject> element in notif.Payload.AdditionalData)
                {
                    notification.payload.additionalData.Add((Foundation.NSString)element.Key, element.Value);
                }
            }

            notification.payload.badge            = (int)notif.Payload.Badge;
            notification.payload.body             = notif.Payload.Body;
            notification.payload.contentAvailable = notif.Payload.ContentAvailable;
            notification.payload.launchURL        = notif.Payload.LaunchURL;
            notification.payload.notificationID   = notif.Payload.NotificationID;
            notification.payload.sound            = notif.Payload.Sound;
            notification.payload.subtitle         = notif.Payload.Subtitle;
            notification.payload.title            = notif.Payload.Title;

            return(notification);
        }
示例#12
0
        public virtual object GetView(UIApplicationDelegate value)
        {
            //
            // Is there a window? If so, show that
            //
            if (value.Window != null)
            {
                return(GetView(value.Window));
            }

            //
            // What if we fake run the life cycle?
            //
            var launchOptions = new Foundation.NSDictionary();

            try
            {
                value.WillFinishLaunching(UIApplication.SharedApplication, launchOptions);
            }
            catch (Exception)
            {
            }
            try
            {
                value.FinishedLaunching(UIApplication.SharedApplication, launchOptions);
            }
            catch (Exception)
            {
            }
            if (value.Window != null)
            {
                return(GetView(value.Window));
            }

            //
            // Just show the object inspector
            //
            return(null);
        }
示例#13
0
        private static BootstrapperConfig CreateBootstrapperConfig(UIKit.UIApplication application, Foundation.NSDictionary launchOptions)
        {
            var config = new BootstrapperConfig();

            config.SetSimpleIoc(new SimpleIoc());

            return(config);
        }
示例#14
0
 public static bool OpenUrl(this IWebAuthenticator webAuthenticator, UIKit.UIApplication app, Foundation.NSUrl url, Foundation.NSDictionary options) =>
 webAuthenticator.OpenUrl(new Uri(url.AbsoluteString));
示例#15
0
        /// <summary>
        /// Initializes a Manager that stores Databases in the given directory.
        /// </summary>
        /// <param name="directoryFile"><see cref="System.IO.DirectoryInfo"/> object for initializing the Manager object.</param>
        /// <param name="options">Option flags for initialization.</param>
        /// <exception cref="T:System.IO.DirectoryNotFoundException">Thrown when there is an error while accessing or creating the given directory.</exception>
        public Manager(DirectoryInfo directoryFile, ManagerOptions options)
        {
            if (directoryFile == null)
            {
                Log.To.Database.E(TAG, "directoryFile cannot be null in ctor, throwing...");
                throw new ArgumentNullException("directoryFile");
            }

            this.directoryFile = directoryFile;
            Options            = options ?? DefaultOptions;
            this.databases     = new Dictionary <string, Database>();
            this.replications  = new List <Replication>();
            Shared             = new SharedState();

            //create the directory, but don't fail if it already exists
            if (!directoryFile.Exists)
            {
                directoryFile.Create();
                directoryFile.Refresh();
                if (!directoryFile.Exists)
                {
                    throw Misc.CreateExceptionAndLog(Log.To.Database, StatusCode.InternalServerError, TAG,
                                                     "Unable to create directory {0}", directoryFile);
                }
            }

            UpgradeOldDatabaseFiles(directoryFile);

#if __IOS__
            Foundation.NSString protection;
            switch (options.FileProtection & Foundation.NSDataWritingOptions.FileProtectionMask)
            {
            case Foundation.NSDataWritingOptions.FileProtectionNone:
                protection = Foundation.NSFileManager.FileProtectionNone;
                break;

            case Foundation.NSDataWritingOptions.FileProtectionComplete:
                protection = Foundation.NSFileManager.FileProtectionComplete;
                break;

            case Foundation.NSDataWritingOptions.FileProtectionCompleteUntilFirstUserAuthentication:
                protection = Foundation.NSFileManager.FileProtectionCompleteUntilFirstUserAuthentication;
                break;

            default:
                protection = Foundation.NSFileManager.FileProtectionCompleteUnlessOpen;
                break;
            }

            var attributes = new Foundation.NSDictionary(Foundation.NSFileManager.FileProtectionKey, protection);
            Foundation.NSError error;
            Foundation.NSFileManager.DefaultManager.SetAttributes(attributes, directoryFile.FullName, out error);
#endif

            var scheduler = options.CallbackScheduler;
            CapturedContext = new TaskFactory(scheduler);
            Log.To.TaskScheduling.I(TAG, "Callbacks will be scheduled on {0}", scheduler);
            workExecutor = new TaskFactory(new SingleTaskThreadpoolScheduler());
            _networkReachabilityManager = new NetworkReachabilityManager();
            _networkReachabilityManager.StartListening();
            StorageType = "SQLite";
            Log.To.Database.I(TAG, "Created {0}", this);
        }
示例#16
0
 public virtual override AppKit.NSImageRep BestRepresentationForDevice(Foundation.NSDictionary deviceDescription)
 {
     throw new NotImplementedException();
 }
      public OneSignalIOS(string appId, bool autoPrompt, bool inAppLaunchURLs, OneSignal.OSInFocusDisplayOption displayOption, OneSignal.LOG_LEVEL logLevel, OneSignal.LOG_LEVEL visualLevel)
      {
         var convertedLogLevel = (iOS.OneSLogLevel)((int)logLevel);
         var convertedVisualLevel = (iOS.OneSLogLevel)((int)visualLevel);

         iOS.OneSignal.SetLogLevel(convertedLogLevel, convertedVisualLevel);
         var dict = new Foundation.NSDictionary("kOSSettingsKeyInAppLaunchURL", new Foundation.NSNumber(inAppLaunchURLs), 
                                                "kOSSettingsKeyAutoPrompt", new Foundation.NSNumber(autoPrompt),
                                                "kOSSettingsKeyInFocusDisplayOption", new Foundation.NSNumber((int)displayOption)
                                               );
         iOS.OneSignal.InitWithLaunchOptions(new Foundation.NSDictionary(), appId, NotificationReceivedHandler, NotificationOpenedHandler, dict);

      }
示例#18
0
 public virtual override void Draw(CoreGraphics.CGRect dstSpacePortionRect, CoreGraphics.CGRect srcSpacePortionRect, AppKit.NSCompositingOperation op, nfloat requestedAlpha, bool respectContextIsFlipped, Foundation.NSDictionary hints)
 {
 }
示例#19
0
        public void GetTagsHandler(Foundation.NSDictionary result)
        {
            Dictionary <string, object> dict = NSDictToPureDict(result);

            OneSignal.onTagsReceived(dict);
        }
        public void PostNotificationSuccessHandler(Foundation.NSDictionary result)
        {
            Dictionary <string, object> dict = NSDictToPureDict(result);

            onPostNotificationSuccess(dict);
        }
示例#21
0
 //
 // This method is invoked when the application has loaded and is ready to run. In this
 // method you should instantiate the window, load the UI into it and then make the window
 // visible.
 //
 // You have 17 seconds to return from this method, or iOS will terminate your application.
 //
 public override bool FinishedLaunching(UIKit.UIApplication app, Foundation.NSDictionary options)
 {
     Xamarin.Forms.Forms.Init();
     LoadApplication(new App());
     return(base.FinishedLaunching(app, options));
 }
示例#22
0
 public override void Bind(Foundation.NSString binding, Foundation.NSObject observable, string keyPath, Foundation.NSDictionary options)
 {
 }
示例#23
0
 public virtual override void ObserveValue(Foundation.NSString keyPath, Foundation.NSObject ofObject, Foundation.NSDictionary change, IntPtr context)
 {
 }
示例#24
0
        public void GetTagsHandler(Foundation.NSDictionary result)
        {
            Dictionary <string, object> dict = NSDictToPureDict(result);

            Com.OneSignal.OneSignal.tagsAvailableDelegate(dict);
        }
示例#25
0
 public virtual override void SetValuesForKeysWithDictionary(Foundation.NSDictionary keyedValues)
 {
 }
示例#26
0
 public override bool FinishedLaunching(UIApplication app, Foundation.NSDictionary launchOptions)
 {
     Logger.Log("Finite-Length Tasks Demo. Press home button to start a Finite-Length Task.");
     Logger.Log("FinishedLaunching() - started from scratch");
     return(true);
 }
示例#27
0
        public void NotificationOpenedHandler(string message, Foundation.NSDictionary additionalData, bool isActive)
        {
            Dictionary <string, object> dict = NSDictToPureDict(additionalData);

            Com.OneSignal.OneSignal.notificationOpenedDelegate(message, dict, isActive);
        }
示例#28
0
 public override bool FinishedLaunching(UIApplication uiApplication, Foundation.NSDictionary launchOptions)
 {
     FireLifetimeChanged(MvxLifetimeEvent.Launching);
     return(base.FinishedLaunching(uiApplication, launchOptions));
 }
示例#29
0
        public void PostNotificationSuccessHandler(Foundation.NSDictionary result)
        {
            Dictionary <string, object> dict = NSDictToPureDict(result);

            Com.OneSignal.OneSignal.onPostNotificationSuccessDelegate(dict);
        }
        /// <summary>
        /// Indicates that the value at the specified keyPath relative to this object has changed.
        /// </summary>
        /// <param name="keyPath">Key-path to use to perform the value lookup.   The keypath consists of a series of lowercase ASCII-strings with no spaces in them separated by dot characters.</param>
        /// <param name="ofObject">The of object.</param>
        /// <param name="change">A dictionary that describes the changes that have been made to the value of the property at the key path keyPath relative to object. Entries are described in Change Dictionary Keys.</param>
        /// <param name="context">The value that was provided when the receiver was registered to receive key-value observation notifications.</param>
        /// <remarks>This method is invoked if you have registered an observer using the <see cref="M:Foundation.NSObject.AddObserver" /> method</remarks>
        public override void ObserveValue(Foundation.NSString keyPath, Foundation.NSObject ofObject, Foundation.NSDictionary change, IntPtr context)
        {
            if (Equals(ofObject, _player))
            {
                if (keyPath.Equals((Foundation.NSString) "status"))
                {
                    if (_player.Status == AVPlayerStatus.ReadyToPlay)
                    {
                        System.Diagnostics.Debug.WriteLine("Player ReadyToPlay");

                        Element.OnMediaLoaded();

                        if (Element.AutoPlay)
                        {
                            Element.PlayCommand.Execute(null);
                        }
                    }
                }
                else if (keyPath.Equals((Foundation.NSString) "error") && _player.Error != null)
                {
                    System.Diagnostics.Debug.WriteLine("Error");

                    Element.OnMediaErrorOccurred(_player.Error?.LocalizedDescription ?? "Error loading player");
                }
            }

            //base.ObserveValue(keyPath, ofObject, change, context);
        }
示例#31
0
 public override bool FinishedLaunching(UIApplication uiApplication, Foundation.NSDictionary launchOptions)
 {
     Windows.UI.Xaml.Application.Start(_ => new App());
     return(base.FinishedLaunching(uiApplication, launchOptions));
 }
示例#32
0
		public virtual object GetView (UIApplicationDelegate value)
		{
			//
			// Is there a window? If so, show that
			//
			if (value.Window != null)
			{
				return GetView (value.Window);
			}

			//
			// What if we fake run the life cycle?
			//
			var launchOptions = new Foundation.NSDictionary ();
			try
			{
				value.WillFinishLaunching (UIApplication.SharedApplication, launchOptions);
			}
			catch (Exception)
			{
			}
			try
			{
				value.FinishedLaunching (UIApplication.SharedApplication, launchOptions);
			}
			catch (Exception)
			{
			}
			if (value.Window != null)
			{
				return GetView (value.Window);
			}

			//
			// Just show the object inspector
			//
			return null;
		}