When I develop an app, I found that notification is disappeared when app is removed or updated. There was no source code to unregister notification on my app.
I guess that when app is removed or updated, ACTION_PACKAGE_REMOVED intent will be broadcasted. And something call cancel() method on NotificationManager after receive it.
Is there anyone who know this mechanism or logic?
The package which is being removed will not receive this intent. See documentation here: https://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED
It seems like there is no way to track your app being removed.