private OSNotificationOpenedResult OSNotificationOpenedResultToNative(iOS.OSNotificationOpenedResult result)
      {
         var openresult = new OSNotificationOpenedResult();
         openresult.action = new OSNotificationAction();
         iOS.OSNotificationAction action = result.Action;
         openresult.action.actionID = action.ActionID;
         openresult.action.type = (OSNotificationAction.ActionType)(int)action.Type;

         openresult.notification = OSNotificationToNative(result.Notification);

         return openresult;
      }
      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;
      }
Example #3
0
        private static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            var options = new CommandLineOptions();

            // allow app to be debugged in visual studio.
            if (Debugger.IsAttached)
            {
                // args = "--help ".Split(' ');
                args = "--platform=essentials".Split(' ');

                // args = new[]
                // {
                //    "--platform=none",
                //    @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Xamarin.iOS.dll"
                // };
            }

            // Parse in 'strict mode'; i.e. success or quit
            if (Parser.Default.ParseArgumentsStrict(args, options))
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(options.Template))
                    {
                        _mustacheTemplate = options.Template;

                        Log.Debug("Using {template} instead of the default template.", _mustacheTemplate);
                    }

                    if (!string.IsNullOrWhiteSpace(options.ReferenceAssemblies))
                    {
                        _referenceAssembliesLocation = options.ReferenceAssemblies;
                        Log.Debug($"Using {_referenceAssembliesLocation} instead of the default reference assemblies location.");
                    }

                    IPlatform platform = null;
                    switch (options.Platform)
                    {
                    case AutoPlatform.None:
                        if (!options.Assemblies.Any())
                        {
                            throw new Exception("Assemblies to be used for manual generation were not specified.");
                        }

                        platform            = new Bespoke();
                        platform.Assemblies = options.Assemblies;

                        if (PlatformHelper.IsRunningOnMono())
                        {
                            platform.CecilSearchDirectories =
                                platform.Assemblies.Select(Path.GetDirectoryName).Distinct().ToList();
                        }
                        else
                        {
                            platform.CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5");
                        }

                        break;

                    case AutoPlatform.Android:
                        platform = new Android(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.iOS:
                        platform = new iOS(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.Mac:
                        platform = new Mac(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.TVOS:
                        platform = new TVOS(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.WPF:
                        platform = new WPF();
                        break;

                    case AutoPlatform.XamForms:
                        platform = new XamForms();
                        break;

                    case AutoPlatform.Tizen:
                        platform = new Tizen();
                        break;

                    case AutoPlatform.UWP:
                        platform = new UWP();
                        break;

                    case AutoPlatform.Winforms:
                        platform = new Winforms();
                        break;

                    case AutoPlatform.Essentials:
                        platform          = new Essentials();
                        _mustacheTemplate = "XamarinEssentialsTemplate.mustache";
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    ExtractEventsFromAssemblies(platform);

                    Environment.Exit((int)ExitCode.Success);
                }
                catch (Exception ex)
                {
                    Log.Fatal(ex.ToString());

                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
            }

            Environment.Exit((int)ExitCode.Error);
        }
Example #4
0
        public static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.AppSettings()
                         .CreateLogger();

            // allow app to be debugged in visual studio.
            if (Debugger.IsAttached)
            {
                args = "--platform=essentials --output-path=test.txt".Split(' ');
            }

            await new Parser(parserSettings => parserSettings.CaseInsensitiveEnumValues = true).ParseArguments <CommandLineOptions>(args).MapResult(
                async options =>
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(options.Template))
                    {
                        _mustacheTemplate = options.Template;

                        Log.Debug("Using {template} instead of the default template.", _mustacheTemplate);
                    }

                    if (!string.IsNullOrWhiteSpace(options.ReferenceAssemblies))
                    {
                        _referenceAssembliesLocation = options.ReferenceAssemblies;
                        Log.Debug($"Using {_referenceAssembliesLocation} instead of the default reference assemblies location.");
                    }

                    IPlatform platform = null;
                    switch (options.Platform)
                    {
                    case AutoPlatform.None:
                        if (options.Assemblies.Any() == false)
                        {
                            throw new Exception("Assemblies to be used for manual generation were not specified.");
                        }

                        platform = new Bespoke();
                        platform.Assemblies.AddRange(options.Assemblies);

                        if (PlatformHelper.IsRunningOnMono())
                        {
                            platform.CecilSearchDirectories.AddRange(platform.Assemblies.Select(Path.GetDirectoryName).Distinct().ToList());
                        }
                        else
                        {
                            platform.CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5");
                        }

                        break;

                    case AutoPlatform.Android:
                        platform = new Android(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.iOS:
                        platform = new iOS(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.Mac:
                        platform = new Mac(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.TVOS:
                        platform = new TVOS(_referenceAssembliesLocation);
                        break;

                    case AutoPlatform.WPF:
                        platform = new WPF();
                        break;

                    case AutoPlatform.XamForms:
                        platform = new XamForms();
                        break;

                    case AutoPlatform.Tizen4:
                        platform = new Tizen();
                        break;

                    case AutoPlatform.UWP:
                        platform = new UWP();
                        break;

                    case AutoPlatform.Winforms:
                        platform = new Winforms();
                        break;

                    case AutoPlatform.Essentials:
                        platform          = new Essentials();
                        _mustacheTemplate = "XamarinEssentialsTemplate.mustache";
                        break;

                    default:
                        throw new ArgumentException($"Platform not {options.Platform} supported");
                    }

                    await ExtractEventsFromAssemblies(options.OutputPath, platform).ConfigureAwait(false);

                    Environment.Exit((int)ExitCode.Success);
                }
                catch (Exception ex)
                {
                    Log.Fatal(ex.ToString());

                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }

                Environment.Exit((int)ExitCode.Error);
            },
                _ => Task.CompletedTask).ConfigureAwait(false);
        }
 public void NotificationReceivedHandler(iOS.OSNotification notification)
 {
    OneSignal.onPushNotificationReceived(OSNotificationToNative(notification));
 }
 public void NotificationOpenedHandler (iOS.OSNotificationOpenedResult result)
 {
    OneSignal.onPushNotificationOpened(OSNotificationOpenedResultToNative(result));
 }