DeLac
DeLac

Reputation: 1122

How to Get info about phone calls

I have to develop a mobile application that monitors some info about calls, to limit users of a company to spend too much time with the phone near their ears. After x minutes, it should suggest to use earphones.

1st question: is it possible to monitor data like this? Phonecall time duration, start and end, if it's using earphones, internal or external speaker.. I mean, without using jailbreak or other hackings.

2nd question: is it possible doing this for IOS and Android?

3rt question: Do you know if Ionic has the capability to that?

Thank you.

Upvotes: 0

Views: 670

Answers (2)

Saurabh Jain
Saurabh Jain

Reputation: 1698

For Android:

  • You can easily get the call history or incoming and outgoing call time. So it is possible in android.

For iOS:

According to your question you want to limit the current calling time of phone near their ears.

So you also do it in iOS by some smartness.

  • In iOS 10 a new framework introduces for calling i.e. CallKit.
  • First, you have to get all contact in your application.
  • So user should call from your app.
  • For dialing also add the custom phone dialer.

By Some method of callKit you can do:

  1. Add a call observer

    @property ( nonatomic ) CXCallObserver *callObserver;

  2. Initialize the call observer:

    • (instancetype)init { self = [super init]; if (self) {

          //Initialize the call observer
          _callObserver = [CXCallObserver new];
          [_callObserver setDelegate:self queue:dispatch_get_main_queue()];
      }
      return self;
      

      }

Add the delegate of call kit

#pragma mark - CXCallObserverDelegate
- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call{
    [self callStateValue:call];
}

#pragma mark - Callkit State
- (void)callStateValue:(CXCall *)call {

    NSLog(@"Call UIID: %@", call.UUID);
    NSLog(@"hasEnded     %@", call.hasEnded? @"YES":@"NO");
    NSLog(@"isOutgoing   %@", call.isOutgoing? @"YES":@"NO");
    NSLog(@"isOnHold     %@", call.isOnHold? @"YES":@"NO");
    NSLog(@"hasConnected %@", call.hasConnected? @"YES":@"NO");

    if (call == nil || call.hasEnded == YES) {
        NSLog(@"CXCallState : Disconnected");
        [timer1 invalidate];
        NSLog(@"%ld",(long)self.duration);
        if(self.duration>1)
        self.duration=1;
    }

    if (call.isOutgoing == YES && call.hasConnected == NO) {
    }

    if (call.isOutgoing == NO  && call.hasConnected == NO && call.hasEnded == NO && call != nil) {
        self.duration = 0;
        NSLog(@"CXCallState : Incoming");
        NSLog(@"Call Details: %@",call);
    }

    if (call.hasConnected == YES && call.hasEnded == NO) {
        NSLog(@"CXCallState : Connected");
    timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
        self.duration++;
        NSLog(@"%ld",(long)self.duration);
    }];

    }
}

You can get the time duration and also add the condition After x minutes, it should suggest to use earphones.

Upvotes: 1

Sivajee Battina
Sivajee Battina

Reputation: 4174

Answering your questions:

Question1: Yes it's possible on Android. It's not possible on iOS. In Android, you can get call information if the user permits. You don't need to do jailbreaking or something. Whereas in iOS no way you can access call info.

Question2: Hope my first answer itself answers this. i.,e Android-Possible, iOS- not Possible

Question 3: AFAIK ionic framework is providing only basic details of Phone call time duration and contacts framework. You should explore more on Android to find out. Even if you use ionic framework you can't access this info at all on iPhone as native ios only not providing these details, we can't expect this from ionic framework.

Upvotes: 2

Related Questions