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
App Extension support #1895
App Extension support #1895
Changes from 8 commits
64a346a
ca52627
7892c0c
93bbe2a
6666395
37aef7a
6a1cc67
839b699
4d6893d
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 |
---|---|---|
|
@@ -337,6 +337,42 @@ BOOL RCTRunningInTestEnvironment(void) | |
return isTestEnvironment; | ||
} | ||
|
||
BOOL RCTRunningInAppExtension(void) | ||
{ | ||
return [[[[NSBundle mainBundle] bundlePath] pathExtension] isEqualToString:@"appex"]; | ||
} | ||
|
||
id RCTSharedApplication(void) | ||
{ | ||
if (RCTRunningInAppExtension()) { | ||
return nil; | ||
} | ||
|
||
return [[UIApplication class] performSelector:@selector(sharedApplication)]; | ||
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. Do we still need the performSelector call here? 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. I think the 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. Just wondering why it's necessary in this case but not in the case of UIAlertView for example. This code is probably fine, but ARC and performSelector don't always work well together. 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. The UIAlertView slips through because it's using I think (but could be mistaken) that performSelector and ARC are only problematic if the selector isn't known at compile time (i.e. you're using |
||
} | ||
|
||
id RCTAlertView(NSString *title, NSString *message, id delegate, NSString *cancelButtonTitle, NSArray *otherButtonTitles) | ||
{ | ||
if (RCTRunningInAppExtension()) { | ||
RCTLogError(@"RCTAlertView is unavailable when running in an app extension"); | ||
return nil; | ||
} | ||
|
||
UIAlertView *alertView = [[UIAlertView alloc] init]; | ||
alertView.title = title; | ||
alertView.message = message; | ||
alertView.delegate = delegate; | ||
if (cancelButtonTitle != nil) { | ||
[alertView addButtonWithTitle:cancelButtonTitle]; | ||
alertView.cancelButtonIndex = 0; | ||
} | ||
for (NSString *buttonTitle in otherButtonTitles) | ||
{ | ||
[alertView addButtonWithTitle:buttonTitle]; | ||
} | ||
return alertView; | ||
} | ||
|
||
BOOL RCTImageHasAlpha(CGImageRef image) | ||
{ | ||
switch (CGImageGetAlphaInfo(image)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
#import "RCTAssert.h" | ||
#import "RCTLog.h" | ||
#import "RCTUtils.h" | ||
|
||
@interface RCTAlertManager() <UIAlertViewDelegate> | ||
|
||
|
@@ -69,12 +70,12 @@ - (dispatch_queue_t)methodQueue | |
RCTLogError(@"Must have at least one button."); | ||
return; | ||
} | ||
|
||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title | ||
message:nil | ||
delegate:self | ||
cancelButtonTitle:nil | ||
otherButtonTitles:nil]; | ||
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. nit: whitespace |
||
if (RCTRunningInAppExtension()) { | ||
return; | ||
} | ||
|
||
UIAlertView *alertView = RCTAlertView(title, nil, self, nil, nil); | ||
|
||
NSMutableArray *buttonKeys = [[NSMutableArray alloc] initWithCapacity:buttons.count]; | ||
|
||
|
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.
nit: can you remove the whitespace here?