@@ -93,7 +93,13 @@ Make sure you enabled the folowing in `Xcode` -> `Signing & Capabilities`:
93
93
94
94
- (BOOL)application:(UIApplication * )application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions
95
95
{
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 ] ;
97
103
}
98
104
99
105
...
@@ -171,7 +177,34 @@ On RN60+, auto linking with pod file should work.
171
177
- In ` Header Search Paths ` , add ` $(SRCROOT)/../node_modules/react-native-voip-push-notification/ios/RNVoipPushNotification ` with ` recursive `
172
178
</details>
173
179
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
175
208
176
209
``` javascript
177
210
0 commit comments