rns-nativecall 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +27 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -3,6 +3,8 @@ import {
3
3
  NativeEventEmitter,
4
4
  AppRegistry,
5
5
  Platform,
6
+ PermissionsAndroid, // Import this
7
+ Linking,
6
8
  } from 'react-native';
7
9
 
8
10
  const { CallModule } = NativeModules;
@@ -80,6 +82,31 @@ export const CallHandler = {
80
82
 
81
83
  //--------------------------------------------------------------------------------------
82
84
 
85
+
86
+ requestNotificationPermission: async () => {
87
+ if (Platform.OS === 'android') {
88
+ // Android 13+ (API 33+) requires the RUNTIME prompt
89
+ if (Platform.Version >= 33) {
90
+ const status = await PermissionsAndroid.request('android.permission.POST_NOTIFICATIONS');
91
+ return status === PermissionsAndroid.RESULTS.GRANTED;
92
+ }
93
+
94
+ // Android 12 and below: Permissions are granted at install.
95
+ // If they are missing, it means the user MANUALLY disabled them.
96
+ // You can't "request" them back via code; you must send them to Settings.
97
+ await PermissionsAndroid.check('android.permission.POST_NOTIFICATIONS');
98
+
99
+ return true; // Assume true for old versions, or use Linking if you suspect a block
100
+ }
101
+ return true; // iOS (handled by CallKit)
102
+ },
103
+
104
+ goToSettings: () => {
105
+ if (Platform.OS === 'android') {
106
+ Linking.openSettings();
107
+ }
108
+ },
109
+
83
110
  requestOverlayPermission: async () => {
84
111
  if (Platform.OS === 'ios') return true;
85
112
  if (!CallModule?.requestOverlayPermission) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rns-nativecall",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "High-performance React Native module for handling native VoIP call UI on Android and iOS.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",