Repository navigation
Conversation
|
Hi @pinpong, First of all, thank you for taking the time to contribute! You identified a genuine gap in the library's notification permission API, and I really appreciate both the suggestion and the testing you performed. After reviewing the PR, I decided to implement the feature independently rather than merge the proposed changes. The main concern was the public API contract, not the underlying idea. Android's shouldShowRequestPermissionRationale() indicates whether displaying an explanatory UI is recommended, but it doesn't reliably tell us whether another permission dialog will appear. The proposed documentation made stronger guarantees than Android actually provides, particularly regarding repeated denials. I also wanted to handle the missing Activity case explicitly rather than returning false, which could be mistaken for a valid platform response. The feature has now been implemented and released in react-native-notify-kit@10.10.0, with these refinements, additional native regression tests, and successful validation on physical Android and iOS devices. Since the functionality is now available in v10.10.0, I'll close this PR without merging it. Thanks again for bringing this improvement to my attention. Your suggestion helped make the library better, and I really appreciate your contribution! |
What
Adds
shouldShowRequestPermissionRationale(): Promise<boolean>. On Android 13+ it wrapsActivity.shouldShowRequestPermissionRationale(POST_NOTIFICATIONS). Below API 33, without a current Activity and on iOS it resolvesfalse.Why
After the first denial
getNotificationSettings()saysDENIEDboth when Android would show the dialog once more and when only the system settings can help. With this check an app can follow the Android guidelines: explain first and callrequestPermission()while the dialog can still come, and offeropenNotificationSettings()once it can't.Changes
All in the bridge, NotifeeCore is untouched.
src/specs/NativeNotifeeModule.ts: new spec methodsrc/NotifeeApiModule.ts,src/types/Module.ts: public API with docsandroid/.../NotifeeApiModule.kt: native implementationios/RNNotifee/NotifeeApiModule.mm: stub that resolvesNO, like the other Android only methodsjest-mock.js,src/__mocks__/NotifeeNativeModule.ts: mocks__tests__/NotifeeApiModule.test.ts: iOS and Android casesdocs/react-native/android/permissions.mdx: new "Asking again after a denial" sectiondocs/react-native/reference/Interface.ModuleWithStatics.mdx: regenerated withyarn gen:referenceREADME.md,packages/react-native/README.md: short entry under "New APIs"CHANGELOG.md: entry under UnreleasedTesting
Same change as a Yarn patch on 10.9.1 in a production app (RN 0.88, new architecture):
truefalse, the dialog doesn't come backfalsewithout a native call.On this branch:
yarn validate:all: no errorsyarn test:core:android(JDK 21): build successful, 806/806 tests passedyarn tests_rn:test: the new tests pass.__tests__/validators/assetResolution.test.tsfails in my local install withCannot find module 'react' from '@react-native/jest-preset/jest/mockComponent.js', the same onmain, so it is not related to this change.