localnotificationsplugin icon indicating copy to clipboard operation
localnotificationsplugin copied to clipboard

Added custom data and default sound in local notifications

Open fbua opened this issue 8 years ago • 3 comments

Changes proposed in this pull request:

  • Play default notification sound
  • Functionality to attach custom string on notification in order to retrieve it after app is started Examples Android:
protected override void OnCreate(Bundle bundle)
{   
   [...]
   if (Intent.HasExtra(CrossLocalNotifications.LocalNotificationCustomData))
   {
      var data = Intent.GetStringExtra(CrossLocalNotifications.LocalNotificationCustomData);
   }
}

UWP:

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
   [...]
   if (!string.IsNullOrWhiteSpace(e.Arguments) && e.Arguments.StartsWith(CrossLocalNotifications.LocalNotificationCustomData))
   {
      var data = e.Arguments.Replace(CrossLocalNotifications.LocalNotificationCustomData + "=", string.Empty);
   }
}

iOS:

public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)        {
   var key = FromObject(CrossLocalNotifications.LocalNotificationCustomData);
   if (notification.UserInfo != null && notification.UserInfo.ContainsKey(key))
   {
      var data = notification.UserInfo[key].ToString();
   }
}

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
   [...]
   if (options != null && options.ContainsKey(FromObject("UIApplicationLaunchOptionsLocalNotificationKey")))
   {
      var notification = (UILocalNotification)options["UIApplicationLaunchOptionsLocalNotificationKey"];
      ReceivedLocalNotification(app, notification);
   }
}

fbua avatar Aug 05 '17 00:08 fbua

@fbua would you mind fixing the conflicts?

karlingen avatar Jan 19 '19 08:01 karlingen

@fbua would you mind fixing the conflicts? @karlingen I created this fork for an old project that I don't support anymore

fbua avatar Feb 01 '19 22:02 fbua

Any news about this ?

lavilaso avatar Dec 10 '19 18:12 lavilaso