-
Notifications
You must be signed in to change notification settings - Fork 509
Support IOS setup in AppDelegate.m #394
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
Changes from all commits
19413af
479046c
4690abc
e5607f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #import <React/RCTConvert.h> | ||
| #import <React/RCTEventDispatcher.h> | ||
| #import <React/RCTUtils.h> | ||
| #import <React/RCTLog.h> | ||
|
|
||
| #import <AVFoundation/AVAudioSession.h> | ||
|
|
||
|
|
@@ -43,6 +44,7 @@ @implementation RNCallKeep | |
| NSMutableArray *_delayedEvents; | ||
| } | ||
|
|
||
| static bool isSetupNatively; | ||
| static CXProvider* sharedProvider; | ||
|
|
||
| // should initialise in AppDelegate.m | ||
|
|
@@ -55,7 +57,7 @@ - (instancetype)init | |
| #endif | ||
| if (self = [super init]) { | ||
| _isStartCallActionEventListenerAdded = NO; | ||
| _delayedEvents = [NSMutableArray array]; | ||
| if (_delayedEvents == nil) _delayedEvents = [NSMutableArray array]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| return self; | ||
| } | ||
|
|
@@ -118,10 +120,11 @@ - (void)sendEventWithNameWrapper:(NSString *)name body:(id)body { | |
| if (_hasListeners) { | ||
| [self sendEventWithName:name body:body]; | ||
| } else { | ||
| NSDictionary *dictionary = @{ | ||
| @"name": name, | ||
| @"data": body | ||
| }; | ||
| NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys: | ||
| name, @"name", | ||
| body, @"data", | ||
| nil | ||
| ]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| [_delayedEvents addObject:dictionary]; | ||
| } | ||
| } | ||
|
|
@@ -133,8 +136,22 @@ + (void)initCallKitProvider { | |
| } | ||
| } | ||
|
|
||
| + (void)setup:(NSDictionary *)options { | ||
| RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil]; | ||
| [callKeep setup:options]; | ||
| isSetupNatively = YES; | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply allocate the singleton and call setup in there, setting isSetupNatively makes the library ignore further calls to setup from react native. |
||
|
|
||
| RCT_EXPORT_METHOD(setup:(NSDictionary *)options) | ||
| { | ||
| if (isSetupNatively) { | ||
| #ifdef DEBUG | ||
| NSLog(@"[RNCallKeep][setup] already setup"); | ||
| RCTLog(@"[RNCallKeep][setup] already setup in native code"); | ||
| #endif | ||
| return; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we've already initialized from |
||
| } | ||
|
|
||
|
jonastelzio marked this conversation as resolved.
|
||
| #ifdef DEBUG | ||
| NSLog(@"[RNCallKeep][setup] options = %@", options); | ||
| #endif | ||
|
|
@@ -183,7 +200,7 @@ + (void)initCallKitProvider { | |
| supportsHolding:(BOOL)supportsHolding | ||
| supportsDTMF:(BOOL)supportsDTMF | ||
| supportsGrouping:(BOOL)supportsGrouping | ||
| supportsUngrouping:(BOOL)supportsUngrouping) | ||
| supportsUngrouping:(BOOL)supportsUngrouping) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whatever was sitting at the end of this line, xcode insists on deleting it when I save the file 🤷♂️
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whitespace is the devil |
||
| { | ||
| [RNCallKeep reportNewIncomingCall: uuidString | ||
| handle: handle | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose a static method to call setup from
AppDelegate.m