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.
For 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.
By Some method of callKit you can do:
Add a call observer
@property ( nonatomic ) CXCallObserver *callObserver;
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.