public void GetPersistentHashCode(int expected, int id, string tag) { // preapre var tid = new ToastId(id, tag); // act & verify Assert.Equal(expected, tid.GetPersistentHashCode()); }
static PendingIntent CreateContentOrDeleteIntent(string action, IPlatformNotificationBuilder builder, ToastId toastId) { var intent = new Intent(action); toastId.ToIntent(intent); builder.AddCustomArgsTo(intent); var result = PendingIntent.GetBroadcast(Application.Context, toastId.GetPersistentHashCode(), intent, 0) ?? throw new InvalidOperationException(ErrorStrings.KBroadcastError); return(result); }
public PendingIntent RegisterToShowWithDelay(IPlatformNotificationBuilder builder, ToastId toastId) { if (builder.UsingCustomContentIntent == false) { SetContentIntent(builder, toastId); } var notification = builder.Build(); var intent = new Intent(IntentConstants.KScheduled); toastId.ToIntent(intent); intent.PutExtra(IntentConstants.KNotification, notification); var pendingIntent = PendingIntent.GetBroadcast(Application.Context, toastId.GetPersistentHashCode(), intent, PendingIntentFlags.CancelCurrent) ?? throw new InvalidOperationException(ErrorStrings.KBroadcastError); return(pendingIntent); }
PendingIntent CreateLaunchIntent(IPlatformNotificationBuilder builder, ToastId toastId) { var packageManager = Application.Context.PackageManager; var intent = packageManager?.GetLaunchIntentForPackage(options.PackageName); if (intent == null) { throw new InvalidOperationException("can't get launch intent"); } intent.AddFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop); toastId.ToIntent(intent); builder.AddCustomArgsTo(intent); var result = PendingIntent.GetActivity(Application.Context, toastId.GetPersistentHashCode(), intent, PendingIntentFlags.UpdateCurrent) ?? throw new InvalidOperationException(ErrorStrings.KBroadcastError); return(result); }
public PendingIntent?GetPendingIntentById(ToastId toastId) => PendingIntent.GetBroadcast(Application.Context, toastId.GetPersistentHashCode(), new Intent(IntentConstants.KScheduled), PendingIntentFlags.NoCreate);