Skip to content

Commit 7617392

Browse files
committed
readme: add api usage and voipRegistration in AppDelegate.m usage memo
1 parent b242ffb commit 7617392

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ Make sure you enabled the folowing in `Xcode` -> `Signing & Capabilities`:
9393

9494
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
9595
{
96-
...
96+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
97+
98+
// --- (THIS IS OPTIONAL)
99+
// --- register VoipPushNotification here ASAP rather than in JS. Doing this from the JS side may be too slow for some use cases
100+
[RNVoipPushNotificationManager voipRegistration];
101+
102+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"AppName" initialProperties:nil];
97103
}
98104

99105
...
@@ -171,7 +177,34 @@ On RN60+, auto linking with pod file should work.
171177
- In `Header Search Paths`, add `$(SRCROOT)/../node_modules/react-native-voip-push-notification/ios/RNVoipPushNotification` with `recursive`
172178
</details>
173179

174-
## Usage:
180+
## API and Usage:
181+
182+
#### Native API
183+
184+
Voip Push is time sensitive, these native API mainly used in AppDelegate.m, especially before JS bridge is up.
185+
This usually
186+
187+
* `(void)voipRegistration`
188+
register delegate for PushKit if you like to register in AppDelegate.m ASAP instead JS side ( too late for some use cases )
189+
* `(void)didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type`
190+
call this api to fire 'register' event to JS
191+
* `(void)didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type`
192+
call this api to fire 'notification' event to JS
193+
* `(void)addCompletionHandler:(NSString *)uuid completionHandler:(RNVoipPushNotificationCompletion)completionHandler`
194+
add completionHandler to RNVoipPush module
195+
* `(void)removeCompletionHandler:(NSString *)uuid`
196+
remove completionHandler to RNVoipPush module
197+
198+
#### JS API:
199+
200+
* `registerVoipToken()` --- JS method to register PushKit delegate
201+
* `onVoipNotificationCompleted(notification.uuid)` --- JS mehtod to tell PushKit we have handled received voip push
202+
203+
#### Events:
204+
205+
* `'register'` --- fired when PushKit give us the latest token
206+
* `'notification'` --- fired when received voip push notification
207+
* `'didLoadWithEvents'` --- fired when there are not-fired events been cached before js bridge is up
175208

176209
```javascript
177210

0 commit comments

Comments
 (0)