/// <summary>
 /// Add the notification manager and other services to the service collection.
 /// Services to be added to the collection:
 /// <seealso cref="IToastOptions"/>,<br/>
 /// <seealso cref="INotificationManager"/>,<br/>
 /// <seealso cref="IHistory"/>,<br/>
 /// <seealso cref="INotificationEventSource"/>,<br/>
 /// <seealso cref="ISystemEventSource"/>,<br/>
 /// <seealso cref="IExtensionConfiguration{T}"/><br/>
 /// </summary>
 /// <param name="this">Service collection</param>
 /// <param name="options">Additional options</param>
 /// <param name="defaultConfiguration">Default configuration for <see cref="IPlatformSpecificExtension"/></param>
 /// <returns>Service collection from @this parameter</returns>
 public static IServiceCollection AddNotificationManager(this IServiceCollection @this,
                                                         IToastOptions options,
                                                         Action <IPlatformSpecificExtension> defaultConfiguration)
 {
     _ = defaultConfiguration ?? throw new ArgumentNullException(nameof(defaultConfiguration));
     return(@this.AddNotificationManager(options)
            .AddSingleton <IExtensionConfiguration <IPlatformSpecificExtension> >(
                sp => new DefaultConfiguration <IPlatformSpecificExtension>(defaultConfiguration)));
 }
 internal NotificationManager(IToastOptions options)
 {
     this.options                    = options ?? throw new ArgumentNullException(nameof(options));
     this.snackbarExtension          = typeof(ISnackbarExtension);
     this.notificationExtension      = typeof(IDroidNotificationExtension);
     this.androidNotificationManager = NewAndroidNotificationManager();
     this.systemEventSource          = new SystemEventSource(null);
     this.intentManager              = new IntentManager(options, androidNotificationManager, systemEventSource, null);
     this.history                    = new History(intentManager, androidNotificationManager);
 }
 internal NotificationManager(IToastOptions options, IPermission permission)
 {
     this.notificationExtension      = typeof(IIosNotificationExtension);
     this.localNotificationExtension = typeof(IIosLocalNotificationExtension);
     this.options              = options;
     this.systemEventSource    = new SystemEventSource(null);
     this.notificationReceiver = new NotificationReceiver(systemEventSource);
     this.permission           = permission;
     this.history              = new History();
 }
Пример #4
0
        public NotificationBuilder(IToastOptions options, INotificationReceiver notificationReceiver, IPermission permission, IServiceProvider?serviceProvider)
        {
            this.options = options;
            this.notificationReceiver = notificationReceiver;
            this.permission           = permission;
            this.serviceProvider      = serviceProvider;
            this.Notification         = new UNMutableNotificationContent();
            this.attachments          = new List <UNNotificationAttachment>();
            if (options.Sound != null)
            {
                Notification.Sound = options.Sound;
            }

            this.UseConfigurationFrom <IIosNotificationExtension>(serviceProvider);
            this.UseConfigurationFrom <IPlatformSpecificExtension>(serviceProvider);
        }
        public IntentManager(
            IToastOptions options,
            IAndroidNotificationManager androidNotificationManager,
            ISystemEventSource systemEventSource,
            IServiceProvider?serviceProvider)
        {
            this.mutex = new object();
            this.tasksByNotificationId = new Dictionary <ToastId, TaskCompletionSource <NotificationResult> >();
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            this.androidNotificationManager = androidNotificationManager;
            this.systemEventSource          = systemEventSource;
            this.logger       = serviceProvider?.GetService <ILogger <IntentManager> >();
            this.intentFilter = new IntentFilter();
            this.receiver     = new NotificationReceiver(this);

            intentFilter.AddAction(IntentConstants.KTapped);
            intentFilter.AddAction(IntentConstants.KDismissed);
            intentFilter.AddAction(IntentConstants.KScheduled);

            Application.Context.RegisterReceiver(receiver, intentFilter);
        }
Пример #6
0
        public NotificationBuilder(
            IToastOptions options,
            IIntentManager intentManager,
            IAndroidNotificationManager androidNotificationManager,
            IServiceProvider?serviceProvider)
        {
            this.options       = options ?? throw new ArgumentNullException(nameof(options));
            this.intentManager = intentManager ?? throw new ArgumentNullException(nameof(intentManager));
            this.androidNotificationManager = androidNotificationManager;
            this.serviceProvider            = serviceProvider;
            this.UseConfigurationFrom <IDroidNotificationExtension>(serviceProvider);
            this.UseConfigurationFrom <IPlatformSpecificExtension>(serviceProvider);
            if (serviceProvider != null)
            {
                this.logger = serviceProvider.GetService <ILogger <NotificationBuilder> >();
            }

            this.Timeout = TimeSpan.FromSeconds(7);
            builder      = new NotificationCompat.Builder(Application.Context, options.ChannelOptions.Id);
            customArgs   = new Dictionary <string, string>();
        }
 public SnackbarNotification(IToastOptions options, ISnackbarBuilder snackbarBuilder)
 {
     this.options         = options;
     this.snackbarBuilder = snackbarBuilder;
 }
 /// <summary>
 /// Initializes a singleton <see cref="Instance"/>.
 /// </summary>
 /// <param name="options">Platform defaults.</param>
 public static void Init(IToastOptions options)
 => instance = new NotificationManager(options);
Пример #9
0
 public Permission(IToastOptions toastOptions) => this.toastOptions = toastOptions;
 /// <summary>
 /// Add the notification manager and other services to the service collection.
 /// Services to be added to the collection:
 /// <seealso cref="IToastOptions"/>,<br/>
 /// <seealso cref="INotificationManager"/>,<br/>
 /// <seealso cref="IHistory"/>,<br/>
 /// <seealso cref="INotificationEventSource"/>,<br/>
 /// <seealso cref="ISystemEventSource"/>,<br/>
 /// <seealso cref="IExtensionConfiguration{T}"/><br/>
 /// </summary>
 /// <param name="this">Service collection</param>
 /// <param name="options">Additional options</param>
 /// <returns>Service collection from @this parameter</returns>
 public static IServiceCollection AddNotificationManager(this IServiceCollection @this, IToastOptions options)
 {
     _ = @this ?? throw new ArgumentNullException(nameof(@this));
     _ = options ?? throw new ArgumentNullException(nameof(options));
     @this.TryAddTransient <INotificationBuilder, NotificationBuilder>();
     @this.TryAddSingleton <IHistory, History>();
     return(@this.AddBase());
 }
 /// <summary>
 /// Add the notification manager and other services to the service collection.
 /// Services to be added to the collection:
 /// <seealso cref="IInitialization"/> with dummy implementation,<br/>
 /// <seealso cref="INotificationManager"/>,<br/>
 /// <seealso cref="IIntentManager"/>,<br/>
 /// <seealso cref="IToastOptions"/>,<br/>
 /// <seealso cref="IAndroidNotificationManager"/>,<br/>
 /// <seealso cref="ISystemEventSource"/>,<br/>
 /// <seealso cref="INotificationEventSource"/>,<br/>
 /// <seealso cref="IHistory"/><br/>
 /// </summary>
 /// <param name="this">Service collection</param>
 /// <param name="options">Additional options</param>
 /// <returns>Service collection from @this parameter</returns>
 public static IServiceCollection AddNotificationManager(this IServiceCollection @this, IToastOptions options)
 {
     _ = @this ?? throw new ArgumentNullException(nameof(@this));
     _ = options ?? throw new ArgumentNullException(nameof(@this));
     @this.TryAddSingleton <IToastOptions>(_ => options);
     @this.TryAddSingleton <IIntentManager, IntentManager>();
     @this.TryAddTransient(typeof(INotificationBuilder), options.NotificationStyle.Resolve(typeof(SnackbarBuilder), typeof(NotificationBuilder)));
     @this.TryAddTransient <ISnackbarExtension, SnackbarBuilder>();
     @this.TryAddTransient <IDroidNotificationExtension, NotificationBuilder>();
     if (AndroidPlatform.IsM)
     {
         @this.TryAddSingleton <IAndroidNotificationManager, AndroidNotificationManagerM>();
     }
     else if (AndroidPlatform.IsEclair)
     {
         @this.TryAddSingleton <IAndroidNotificationManager, AndroidNotificationManagerEclair>();
     }
     else
     {
         @this.TryAddSingleton <IAndroidNotificationManager, AndroidNotificationManager>();
     }
     @this.TryAddSingleton <IHistory, History>();
     return(@this.AddBase());
 }
Пример #12
0
 internal NotificationManager(IToastOptions options)
 {
     this.options           = options ?? throw new ArgumentNullException(nameof(options));
     this.systemEventSource = new SystemEventSource(null);
     this.history           = new History();
 }
 internal NotificationManager(IToastOptions options)
     : this(options, new Permission(options))
 {
 }
Пример #14
0
 /// <summary>
 /// Add the notification manager and other services to the service collection.
 /// Services to be added to the collection:
 /// <seealso cref="IToastOptions"/>,<br/>
 /// <seealso cref="INotificationManager"/>,<br/>
 /// <seealso cref="IHistory"/>,<br/>
 /// <seealso cref="INotificationEventSource"/>,<br/>
 /// <seealso cref="ISystemEventSource"/>,<br/>
 /// <seealso cref="INotificationReceiver"/>,<br/>
 /// <seealso cref="IPermission"/>,<br/>
 /// </summary>
 /// <param name="this">Service collection</param>
 /// <param name="options">Additional options</param>
 /// <returns>Service collection from @this parameter</returns>
 public static IServiceCollection AddNotificationManager(this IServiceCollection @this, IToastOptions options)
 {
     _ = @this ?? throw new ArgumentNullException(nameof(@this));
     _ = options ?? throw new ArgumentNullException(nameof(options));
     @this.TryAddSingleton <IToastOptions>(_ => options);
     @this.TryAddSingleton <INotificationReceiver, NotificationReceiver>();
     @this.TryAddTransient(typeof(INotificationBuilder), UIDevice.CurrentDevice.CheckSystemVersion(10, 0)
         ? typeof(NotificationBuilder) : typeof(LocalNotificationBuilder));
     @this.TryAddTransient <IIosNotificationExtension, NotificationBuilder>();
     @this.TryAddTransient <IIosLocalNotificationExtension, LocalNotificationBuilder>();
     @this.TryAddSingleton <IPermission, Permission>();
     @this.TryAddSingleton(typeof(IInitialization), _ => _.GetService(typeof(IPermission)));
     @this.TryAddSingleton <IHistory, History>();
     return(@this.AddBase());
 }
 public SnackbarBuilder(IToastOptions options, IServiceProvider?serviceProvider)
 {
     this.options         = options ?? throw new ArgumentNullException(nameof(options));
     this.serviceProvider = serviceProvider;
     this.UseConfigurationFrom <ISnackbarExtension>(serviceProvider);
 }