Can a Widget post a Local Notification?

My guess is no... but, I have to ask. I made a widget that checks our GitHub repository for new pull requests - in an attempt to make sure PRs are addressed quicker. It works great - using GitHub's API. It's on my iPhone's Lock Screen. It definitely keeps me more on top of our pull requests!

Our product manager asked if we could also send a local notification when there's a new PR.

I was thinking maybe from the widget - it's updating around every 15 minutes - and if there's a new PR - then maybe it could fire a local notification.

However, there's the permissions. The user has to say "OK" to them. Widget can't do that. Can it inherit the notification permissions from the parent app?

Anyway - I think it is way overkill - I mean we have a widget! Why a notification as well!?!?!?

I thought I'd ask...

Thanks, Scott iOS 17.

I don't know the answer, but I once tried posting a notification from a background asset extension which didn't work. However all the extensions seem a bit different in what they can/cannot do. Why don't you just try it and see what happens, should only take a few minutes coding.

I am happy to announce... it does work! A widget can post a local notification!

The widget even presents the system dialog for notification permissions.

Now we have widgets and notifications - let's see if our pull requests get closed sooner!!!

Can a Widget post a Local Notification?
 
 
Q