cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13535) Add app events for connecting and disconnecting calls
Date Thu, 09 Nov 2017 13:44:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16245659#comment-16245659
] 

ASF GitHub Bot commented on CB-13535:
-------------------------------------

SpencerEJameson closed pull request #348: CB-13535: (ios) Add CallStart/CallEnd events to
fire with Resign/Active events
URL: https://github.com/apache/cordova-ios/pull/348
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CordovaLib/Classes/Public/CDVViewController.m b/CordovaLib/Classes/Public/CDVViewController.m
index d0c05865a..b06fa1767 100644
--- a/CordovaLib/Classes/Public/CDVViewController.m
+++ b/CordovaLib/Classes/Public/CDVViewController.m
@@ -28,6 +28,10 @@ Licensed to the Apache Software Foundation (ASF) under one
 #import "CDVLocalStorage.h"
 #import "CDVCommandDelegateImpl.h"
 #import <Foundation/NSCharacterSet.h>
+#import <CoreTelephony/CTCallCenter.h>
+#import <CoreTelephony/CTCall.h>
+#import <CallKit/CXCallObserver.h>
+#import <CallKit/CXCall.h>
 
 @interface CDVViewController () {
     NSInteger _userAgentLockToken;
@@ -39,6 +43,7 @@ @interface CDVViewController () {
 @property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
 @property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
 @property (nonatomic, readwrite, strong) id <CDVWebViewEngineProtocol> webViewEngine;
+@property (nonatomic, readwrite, strong) CXCallObserver* callObserver;
 
 @property (readwrite, assign) BOOL initialized;
 
@@ -74,6 +79,11 @@ - (void)__init
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
                                                      name:UIApplicationDidEnterBackgroundNotification
object:nil];
 
+         if (IsAtLeastiOSVersion(@"10.0")) {
+             CXCallObserver *callObserver = [[CXCallObserver alloc] init];
+             [callObserver setDelegate:self queue:nil];
+             self.callObserver = callObserver;
+         }
         // read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad,
if its iPad) from -Info.plist
         self.supportedOrientations = [self parseInterfaceOrientations:
             [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]];
@@ -343,9 +353,9 @@ - (void)viewDidLoad
             }
         }
     }];
-    
+
     // /////////////////
-    
+
     NSString* bgColorString = [self.settings cordovaSettingForKey:@"BackgroundColor"];
     UIColor* bgColor = [self colorFromColorString:bgColorString];
     [self.webView setBackgroundColor:bgColor];
@@ -405,16 +415,16 @@ - (UIColor*)colorFromColorString:(NSString*)colorString
     if (!colorString) {
         return nil;
     }
-    
+
     // Validate format
     NSError* error = NULL;
     NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"^(#[0-9A-F]{3}|(0x|#)([0-9A-F]{2})?[0-9A-F]{6})$"
options:NSRegularExpressionCaseInsensitive error:&error];
     NSUInteger countMatches = [regex numberOfMatchesInString:colorString options:0 range:NSMakeRange(0,
[colorString length])];
-    
+
     if (!countMatches) {
         return nil;
     }
-    
+
     // #FAB to #FFAABB
     if ([colorString hasPrefix:@"#"] && [colorString length] == 4) {
         NSString* r = [colorString substringWithRange:NSMakeRange(1, 1)];
@@ -422,22 +432,22 @@ - (UIColor*)colorFromColorString:(NSString*)colorString
         NSString* b = [colorString substringWithRange:NSMakeRange(3, 1)];
         colorString = [NSString stringWithFormat:@"#%@%@%@%@%@%@", r, r, g, g, b, b];
     }
-    
+
     // #RRGGBB to 0xRRGGBB
     colorString = [colorString stringByReplacingOccurrencesOfString:@"#" withString:@"0x"];
-    
+
     // 0xRRGGBB to 0xAARRGGBB
     if ([colorString hasPrefix:@"0x"] && [colorString length] == 8) {
         colorString = [@"0xFF" stringByAppendingString:[colorString substringFromIndex:2]];
     }
-    
+
     // 0xAARRGGBB to int
     unsigned colorValue = 0;
     NSScanner *scanner = [NSScanner scannerWithString:colorString];
     if (![scanner scanHexInt:&colorValue]) {
         return nil;
     }
-    
+
     // int to UIColor
     return [UIColor colorWithRed:((float)((colorValue & 0x00FF0000) >> 16))/255.0
                            green:((float)((colorValue & 0x0000FF00) >>  8))/255.0
@@ -480,9 +490,9 @@ - (BOOL)shouldAutorotate
 }
 
 // CB-12098
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000  
-- (NSUInteger)supportedInterfaceOrientations  
-#else  
+#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
+- (NSUInteger)supportedInterfaceOrientations
+#else
 - (UIInterfaceOrientationMask)supportedInterfaceOrientations
 #endif
 {
@@ -728,6 +738,16 @@ - (void)onAppWillResignActive:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationWillResignActive");
     [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
+
+    if (!IsAtLeastiOSVersion(@"10.0")) {
+        CTCallCenter *callCenter = [[CTCallCenter alloc] init];
+        for (CTCall *call in callCenter.currentCalls)  {
+            if (call.callState == CTCallStateConnected) {
+                [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('callstart');"];
+                break;
+            }
+        }
+    }
 }
 
 /*
@@ -753,6 +773,27 @@ - (void)onAppDidBecomeActive:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationDidBecomeActive");
     [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
+
+    if (!IsAtLeastiOSVersion(@"10.0")) {
+        CTCallCenter *callCenter = [[CTCallCenter alloc] init];
+        for (CTCall *call in callCenter.currentCalls)  {
+            if (call.callState == CTCallStateDisconnected) {
+                [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('callend');"];
+                break;
+            }
+        }
+    }
+}
+
+// Used for iOS 10.0+
+- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
+    if (call.hasEnded) {
+        [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('callend');"];
+    }
+
+    if (call.hasConnected) {
+        [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('callstart');"];
+    }
 }
 
 /*


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add app events for connecting and disconnecting calls
> -----------------------------------------------------
>
>                 Key: CB-13535
>                 URL: https://issues.apache.org/jira/browse/CB-13535
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-ios
>            Reporter: Spencer Jameson
>            Assignee: Suraj Pindoria
>
> The app resign/active events that Cordova fires trigger for multiple phone events. Example:
connecting a call and locking the screen app both trigger the *resign* event, while disconnecting
a call and unlocking the screen trigger the *active* event. It would be convenient to have
distinct events that fire for calls connecting and ending to tie into, aside from the generic
*active* and *resign* events.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message