The API for the new UserNotification Framework for Requesting a Local Notification is Very Confusing

Originator:conrad.stoll
Number:rdar://27950315 Date Originated:22-Aug-2016 11:48 AM
Status:Open Resolved:
Product:watchOS SDK Product Version:watchOS 3
Classification:Serious Bug Reproducible:Always
 
I am using the new UserNotifications framework to trigger local notifications on Apple Watch. When I issue a request with the same unique identifier as the one that is currently presented, nothing happens.  The documentation does mention that the identifier used to request the local notification should be unique, but that was not obvious to me on first use of this new API. Many of the samples I saw online did not use unique identifiers. I didn’t find any sample code from Apple that illustrated clear use of this new framework.

I think it’s strange to ask the user of the framework to create a unique identifier on their own. Now that I’ve spent more time with the framework I think I understand why it was designed this way, but I think the cost is that a very large number of people will make the same mistake I did and not realize how critical it is to have that identifier be unique. It took me several days to figure out what the issue was when my notifications weren’t being delivered.

If the API remains the same and the user needs to supply their own unique identifier then I think other changes need to be made to improve the experience of using this framework

- If no notification is currently presented with the unique identifier, consider presenting a new one
- If a notification was already presented with the unique identifier, and that notification is no longer present, consider throwing an exception
- If a notification was already presented with the unique identifier, consider posting a log message
- Consider providing a new API for updating an already presented notification with a unique identifier to make it more clear why its important to specify a unique identifier
- Consider releasing additional sample code or updated documentation to clearly explain why this is important

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!