-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pass NS app to the native app instead of presenting it over the…
… root VC (#5967) * feat: Pass NS app native controller to the native app instead of presenting it over the rootViewController When NativeScript embedded app is created from the native one we check for whether the topmost UIViewController has NativeScriptEmbedder protocol (implemented in the iOS Runtime) method 'presentNativeScriptApp:'. If yes, we call it with the NS app viewcontroller as a parameter so the embedder has control over the NS app (where and how to present it etc.) For backwards compatibility we present the NS app on top of the topmost UIViewController as a fallback. * style: Fix lint errors * feat: Check for protocol instead of selector in embedding I * Check for rootController instead of topViewController to prevent crash if !rootController * feat: Introduce NativeScriptEmbedder singleton NativeScriptEmbedder is responsive for communication between the NS and the native iOS app. His delegate will implement methods which we can call from javascript such as "presentNativeScriptApp:".
- Loading branch information
1 parent
67f9e06
commit 05c2460
Showing
9 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ libs | |
node_modules | ||
package | ||
platforms | ||
!tns-core-modules/platforms | ||
reports | ||
tags | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## Platform specific native code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// NativeScriptEmbedder.h | ||
// NativeScript | ||
// | ||
// Created by Teodor Dermendzhiev on 6/19/18. | ||
// | ||
#include <UIKit/UIKit.h> | ||
|
||
// When embedding NativeScript application embedder needs to conform to this protocol | ||
// in order to have control over the NativeScript UIViewController | ||
// otherwise NativeScript application is presented over the topmost UIViewController. | ||
@protocol NativeScriptEmbedderDelegate | ||
- (id)presentNativeScriptApp:(UIViewController*)vc; | ||
@end | ||
|
||
@interface NativeScriptEmbedder : NSObject | ||
|
||
@property(nonatomic, retain, readonly) id<NativeScriptEmbedderDelegate> delegate; | ||
|
||
+ (NativeScriptEmbedder *)sharedInstance; | ||
|
||
- (void)setDelegate:(id <NativeScriptEmbedderDelegate>)aDelegate; | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#import "NativeScriptEmbedder.h" | ||
|
||
@implementation NativeScriptEmbedder | ||
|
||
+ (NativeScriptEmbedder *)sharedInstance { | ||
static NativeScriptEmbedder *sharedInstance = nil; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
sharedInstance = [[NativeScriptEmbedder alloc] init]; | ||
}); | ||
|
||
return sharedInstance; | ||
} | ||
|
||
- (void)setDelegate:(id <NativeScriptEmbedderDelegate>)aDelegate { | ||
_delegate = aDelegate; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module NativeScriptEmbedder { | ||
header "NativeScriptEmbedder.h" | ||
export * | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters