Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOIP notification received not able to see incomingCall screen #74

Open
ControlAndC opened this issue Oct 15, 2020 · 0 comments
Open

VOIP notification received not able to see incomingCall screen #74

ControlAndC opened this issue Oct 15, 2020 · 0 comments

Comments

@ControlAndC
Copy link

Hi,

1) I am getting VOIP notification with below payload, What next i am supposed to do to show that incoming call screen ?

---Payload----

[RNVoipPushNotificationManager] didReceiveIncomingPushWithPayload payload.dictionaryPayload = {
    aps =     {
        "content-available" = 1;
    };
    voximplant =     {
        addr = "161.202.172.211:5090";
        "analytics_label" = "";
        callid = x6TgS5RaRiy4aol2rstyHUMq3pAzkk0Nq3DfPGNtWGQ;
        "display_name" = "Sandeep Chacuan";
        sessionid = "BC8630078246B927.1602789509.3391145_161.202.172.211";
        sipuri = "sip:[email protected]";
        userid = "[email protected]";
        video = 1;
    };
}, type = PKPushTypeVoIP

2) When app is in Foreground state i am able to to see incomingCall screen by using below code, i have noticed below i am getting CallId and CallKitUUID from ( _incomingCall = event => ) but when app is in killed state in VOIP payload i am not getting CallKitUUID and even callID format are also different

EX -

CallID in VOIP payload is (app is in killed state)
callid = x6TgS5RaRiy4aol2rstyHUMq3pAzkk0Nq3DfPGNtWGQ;

CallID when app is in Foreground state ( _incomingCall = event => )
event.call.callId = '9BA4BC3CDD7714A9.1602671723.2074451',

Below code to show incoingCall view when app is in Foreground state.

this.callKitManager.showIncomingCall( event.video, event.call.getEndpoints()[0].displayName, event.call.callId, event.call.callKitUUID, );

I am also sharing my AppDelegate.m file.

3) Does below line will call RNCallKeep and show that incomingCall screen or do i need to do something?

if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && ![RNCallKeep isCallActive:uuid]) {
    NSLog(@"AppDelegate: didReceiveIncomingPush: report new incoming call to CallKit");
    NSString *callerName = [[payload.dictionaryPayload valueForKey:@"voximplant"] valueForKey:@"display_name"];
    [RNCallKeep reportNewIncomingCall:uuid handle:callerName handleType:@"generic" hasVideo:YES localizedCallerName:callerName fromPushKit:YES payload:payload.dictionaryPayload];
  }
  completion();
}

This is my AppDelegate.m

#import "AppDelegate.h"
#import <Firebase.h>
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <PushKit/PushKit.h>
#import <UIKit/UIKit.h>
#import "RNVoipPushNotificationManager.h"
#import "RNCallKeep.h"
#import "VIClientModule.h"


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"Mentormatch"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  return YES;
}

// Handle updated push credentials
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
  // Register VoIP push token (a property of PKPushCredentials) with server
  [RNVoipPushNotificationManager didUpdatePushCredentials:credentials forType:(NSString *)type];
}

- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type
{
  // --- The system calls this method when a previously provided push token is no longer valid for use. No action is necessary on your part to reregister the push type. Instead, use this method to notify your server not to send push notifications using the matching push token.
}


// --- Handle incoming pushes (for ios <= 10)
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type {
  [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
}

// Handle incoming pushes
- (void)pushRegistry:(PKPushRegistry *)registry
didReceiveIncomingPushWithPayload:(PKPushPayload *)payload
                          forType:(PKPushType)type
            withCompletionHandler:(void (^)(void))completion {
  // Process the received push
  [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];


  NSString *uuid = [VIClientModule uuidForPushNotification:payload.dictionaryPayload].UUIDString;

  if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
    NSLog(@"AppDelegate: didReceiveIncomingPush: application is in active state");
  }

  if ([RNCallKeep isCallActive:uuid]){
    NSLog(@"AppDelegate: didReceiveIncomingPush: call is already been reported");
  }

  if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && ![RNCallKeep isCallActive:uuid]) {
    NSLog(@"AppDelegate: didReceiveIncomingPush: report new incoming call to CallKit");
    NSString *callerName = [[payload.dictionaryPayload valueForKey:@"voximplant"] valueForKey:@"display_name"];
    [RNCallKeep reportNewIncomingCall:uuid handle:callerName handleType:@"generic" hasVideo:YES localizedCallerName:callerName fromPushKit:YES payload:payload.dictionaryPayload];
  }
  completion();
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant