Skip to content

Releases: react-native-webrtc/react-native-voip-push-notification

Release 3.3.1

05 Dec 20:01
Compare
Choose a tag to compare

Change 3.3.1

8a1ba71 Fix stopObserving on reload issue (#89) ( Romick2005 2022-12-05 21:55:51 +0200)

Release 3.3.0

20 May 09:39
Compare
Choose a tag to compare

Change

  • typescript support
  • Fix singletone class initialisation

3.3.0

452dc9c release 3.3.0 ( zxcpoiu 2021-05-20 02:28:56 -0700)
3e7f1a8 misc: normalize package.json ( zxcpoiu 2021-05-20 01:50:13 -0700)
c299bae #86 Fix singletone class initialisation (#87) ( Romick2005 2021-05-19 11:37:06 +0300)

3.2.0

54356e0 release 3.2.0 ( zxcpoiu 2021-04-17 02:12:48 +0800)
99feae8 feat: add typescript support ( dayze 2021-02-23 11:36:48 +0100)

Release 3.1.0

15 Jan 11:11
Compare
Choose a tag to compare

release 3.1.0

  • remove unused import
  • cache lastVoipToken and return it when subsequently call to registerVoipToken on JS (will fire register event with the cached token immediately, note it may be empty if no token at all)

detailed in #80

Change Log

35a4fe0 readme: update doc for registerVoipToken will fire cached token ( zxcpoiu 2021-01-15 19:03:13 +0800)
bb5485b remove unused import ( zxcpoiu 2021-01-15 18:44:22 +0800)
3d1b675 cache lastVoipToken and return it when subsequently call to registerVoipToken ( zxcpoiu 2021-01-15 18:15:55 +0800)
ab54fd9 readme: update usage doc add some notes ( zxcpoiu 2020-12-08 16:16:07 +0800)

Release 3.0.0

08 Dec 08:23
Compare
Choose a tag to compare

Breaking Change:

Removal and Deprecation

remove unused codes, keep this lib simple, lots functionalities should be easily implemented in the modern RN eco system

  • remove requestPermission ( should use PushNotificationIOS instead if needed )
  • remove wakeupByPush constant with push event ( should use AppState instead if needed )

Changes:

  • use NativeEventEmitter instead the deprecated DeviceEventEmitter
  • tweak event handler logic
  • support caching events before js initialize
    you can subscribe didLoadWithEvents when app ready

Upgrade Guide:

  1. remove deprecation functions or use corresponded 3rd party library to implement it
  2. Follow the new doc in README to tweak your logic

Mainly, you just have to subscribe a new event didLoadWithEvent, which helps you to catch the initial event before JS bridge initialed.
This event

NOTE: You still need to subscribe / handle the rest events as usuall. This is just a helper whcih cache and propagate early fired events if and only if for "the native events which DID fire BEFORE js bridge is initialed", it does NOT mean this will have events each time when the app reopened.

For the discussion, see #69

Doc copied from the readme at the time of writing below

API and Usage:

Native API:

Voip Push is time sensitive, these native API mainly used in AppDelegate.m, especially before JS bridge is up.
This usually

  • (void)voipRegistration ---
    register delegate for PushKit if you like to register in AppDelegate.m ASAP instead JS side ( too late for some use cases )
  • (void)didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type ---
    call this api to fire 'register' event to JS
  • (void)didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type ---
    call this api to fire 'notification' event to JS
  • (void)addCompletionHandler:(NSString *)uuid completionHandler:(RNVoipPushNotificationCompletion)completionHandler ---
    add completionHandler to RNVoipPush module
  • (void)removeCompletionHandler:(NSString *)uuid ---
    remove completionHandler to RNVoipPush module

JS API:

  • registerVoipToken() --- JS method to register PushKit delegate
  • onVoipNotificationCompleted(notification.uuid) --- JS mehtod to tell PushKit we have handled received voip push

Events:

  • 'register' --- fired when PushKit give us the latest token
  • 'notification' --- fired when received voip push notification
  • 'didLoadWithEvents' --- fired when there are not-fired events been cached before js bridge is up

JS usage

...

import VoipPushNotification from 'react-native-voip-push-notification';

...

class MyComponent extends React.Component {

...

    // --- anywhere which is most comfortable and appropriate for you,
    // --- usually ASAP, ex: in your app.js or at some global scope.
    componentDidMount() {

        // --- NOTE: You still need to subscribe / handle the rest events as usuall.
        // --- This is just a helper whcih cache and propagate early fired events if and only if for
        // --- "the native events which DID fire BEFORE js bridge is initialed",
        // --- it does NOT mean this will have events each time when the app reopened.


        // ===== Step 1: subscribe `register` event =====
        // --- this.onVoipPushNotificationRegistered
        VoipPushNotification.addEventListener('register', (token) => {
            // --- send token to your apn provider server
        });

        // ===== Step 2: subscribe `notification` event =====
        // --- this.onVoipPushNotificationiReceived
        VoipPushNotification.addEventListener('notification', (notification) => {
            // --- when receive remote voip push, register your VoIP client, show local notification ... etc
            this.doSomething();
          
            // --- optionally, if you `addCompletionHandler` from the native side, once you have done the js jobs to initiate a call, call `completion()`
            VoipPushNotification.onVoipNotificationCompleted(notification.uuid);
        });

        // ===== Step 3: subscribe `didLoadWithEvents` event =====
        VoipPushNotification.addEventListener('didLoadWithEvents', (events) => {
            // --- this will fire when there are events occured before js bridge initialized
            // --- use this event to execute your event handler manually by event type

            if (!events || !Array.isArray(events) || events.length < 1) {
                return;
            }
            for (let voipPushEvent of events) {
                let { name, data } = voipPushEvent;
                if (name === VoipPushNotification.RNVoipPushRemoteNotificationsRegisteredEvent) {
                    this.onVoipPushNotificationRegistered(data);
                } else if (name === VoipPushNotification.RNVoipPushRemoteNotificationReceivedEvent) {
                    this.onVoipPushNotificationiReceived(data);
                }
            }
        });

        // ===== Step 4: register =====
        // --- it will be no-op ( no event will be fired ) if you have subscribed before like in native side.
        VoipPushNotification.registerVoipToken(); // --- register token
    }

    // --- unsubscribe event listeners
    componentWillUnmount() {
        VoipPushNotification.removeEventListener('didLoadWithEvents');
        VoipPushNotification.removeEventListener('register');
        VoipPushNotification.removeEventListener('notification');
    }
...
}

AppDelegate.m Modification Optional Change

You can now register token ASAP in your AppDelegate.m if you want
This is optional but recommended way

...

#import <PushKit/PushKit.h>                    /* <------ add this line */
#import "RNVoipPushNotificationManager.h"      /* <------ add this line */

...

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  


  // ===== (THIS IS OPTIONAL BUT RECOMMENDED) =====
  // --- register VoipPushNotification here ASAP rather than in JS. Doing this from the JS side may be too slow for some use cases
  // --- see: https://github.com/react-native-webrtc/react-native-voip-push-notification/issues/59#issuecomment-691685841
  [RNVoipPushNotificationManager voipRegistration];
  // ===== (THIS IS OPTIONAL BUT RECOMMENDED) =====



  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"AppName" initialProperties:nil];
}

2.1.0

30 Apr 08:55
Compare
Choose a tag to compare

Release 2.1.0

Support store and execute completion() at js side

Release 2.0.0

27 Dec 16:20
Compare
Choose a tag to compare

This is a Breaking Change

1. update pod file for RN60+

2. separate api requestPermissions() and registerVoipToken()

Original:

request permissions and register voip token in the same function

VoipPushNotification.requestPermissions();

Now:

Separate into two specific functions

VoipPushNotification.requestPermissions(); // --- optional, you can use another library to request permissions
VoipPushNotification.registerVoipToken(); // --- required

Release 1.1.2

07 Sep 05:30
Compare
Choose a tag to compare

20a9719 release 1.1.2 ( zxcpoiu 2018-09-07 13:28:49 +0800)
f3d7733 Add support for alertTitle ( Nicolas Simon 2018-07-25 16:35:19 +0200)