Skip to content

Commit

Permalink
fix(deeplinking): After braking it with the dropbox implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov authored and lyubomir committed Sep 27, 2018
1 parent af37141 commit 467452d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 55 deletions.
46 changes: 32 additions & 14 deletions ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,23 @@ continueUserActivity:(NSUserActivity *)userActivity
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}
```

And also one of the following:

```objc
// See https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623073-application?language=objc
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [JitsiMeetView application:app
openURL:url
options: options];
}
```
or
```objc
// See https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application?language=objc
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
Expand Down Expand Up @@ -215,31 +231,33 @@ user to request entering Picture-in-Picture.

## Dropbox integration

To setup the dropbox integration you need to do the following steps:
To setup the Dropbox integration, follow these steps:

1. Add the following lines in your Info.plist file and replace `<APP_KEY>` with your dropbox app key:
1. Add the following to the app's Info.plist and change `<APP_KEY>` to your
Dropbox app key:
```
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>db-<APP_KEY></string>
</array>
<key>CFBundleURLName</key>
<string></string>
</dict>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>db-<APP_KEY></string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>dbapi-8-emm</string>
<string>dbapi-2</string>
<string>dbapi-2</string>
<string>dbapi-8-emm</string>
</array>
```

2. Add the following method to `AppDelegate`:
2. Add the following to the app's `AppDelegate`:
```objc
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [JitsiMeetView application:app
openURL:url
Expand Down
19 changes: 5 additions & 14 deletions ios/app/src/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,13 @@ - (BOOL)application:(UIApplication *)application
restorationHandler:restorationHandler];
}

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [JitsiMeetView application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}


- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [JitsiMeetView application:app
openURL:url
options: options];
return [JitsiMeetView application:app
openURL:url
options:options];
}

@end
15 changes: 8 additions & 7 deletions ios/sdk/src/JitsiMeetView.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ + (BOOL)application:(UIApplication *)application
restorationHandler:restorationHandler];
}

+ (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return
[Dropbox application:app openURL:url options:options]
|| [RCTLinkingManager application:app openURL:url options:options];
}

+ (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
Expand All @@ -214,13 +222,6 @@ + (BOOL)application:(UIApplication *)application
annotation:annotation];
}

+ (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [Dropbox application:app
openURL:url
options: options];
}

#pragma mark Initializers

- (instancetype)init {
Expand Down
46 changes: 26 additions & 20 deletions ios/sdk/src/dropbox/Dropbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#import <React/RCTBridgeModule.h>
#import <ObjectiveDropboxOfficial/ObjectiveDropboxOfficial.h>

#import "Dropbox.h"

RCTPromiseResolveBlock currentResolve = nil;
Expand All @@ -24,19 +25,19 @@
@implementation Dropbox

+ (NSString *)getAppKey{
NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
for(NSDictionary<NSString *, NSArray *> *urlType in urlTypes) {
NSArray *urlTypes
= [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];

for (NSDictionary<NSString *, NSArray *> *urlType in urlTypes) {
NSArray *urlSchemes = urlType[@"CFBundleURLSchemes"];
if(urlSchemes != nil) {
for(NSString *urlScheme in urlSchemes) {
if(urlScheme != nil) {
if ([urlScheme hasPrefix:@"db-"]) {
return [urlScheme substringFromIndex:3];
}

if (urlSchemes) {
for (NSString *urlScheme in urlSchemes) {
if (urlScheme && [urlScheme hasPrefix:@"db-"]) {
return [urlScheme substringFromIndex:3];
}
}
}

}

return nil;
Expand All @@ -52,7 +53,7 @@ - (NSDictionary *)constantsToExport {
};
};

RCT_EXPORT_METHOD(authorize: (RCTPromiseResolveBlock)resolve
RCT_EXPORT_METHOD(authorize:(RCTPromiseResolveBlock)resolve
reject:(__unused RCTPromiseRejectBlock)reject) {
currentResolve = resolve;
currentReject = reject;
Expand All @@ -75,7 +76,7 @@ - (NSDictionary *)constantsToExport {
resolve(result.name.displayName);
} else {
NSString *msg = @"Failed!";
if (networkError != nil) {
if (networkError) {
msg = [NSString stringWithFormat:@"Failed! Error: %@", networkError];
}
reject(@"getDisplayName", @"Failed", nil);
Expand All @@ -93,7 +94,7 @@ - (NSDictionary *)constantsToExport {
DBUSERSSpaceAllocation *allocation = result.allocation;
NSNumber *allocated = 0;
NSNumber *used = 0;
if([allocation isIndividual]) {
if ([allocation isIndividual]) {
allocated = allocation.individual.allocated;
used = result.used;
} else if ([allocation isTeam]) {
Expand All @@ -108,7 +109,7 @@ - (NSDictionary *)constantsToExport {
resolve(dictionary);
} else {
NSString *msg = @"Failed!";
if (networkError != nil) {
if (networkError) {
msg = [NSString stringWithFormat:@"Failed! Error: %@", networkError];
}
reject(@"getSpaceUsage", msg, nil);
Expand All @@ -117,15 +118,18 @@ - (NSDictionary *)constantsToExport {

}

+ (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
+ (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if (currentReject == nil || currentResolve == nil) {
return NO;
}
DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url];
if (authResult != nil) {
if (authResult) {
if ([authResult isSuccess]) {
currentResolve(authResult.accessToken.accessToken);
currentResolve = nil;
currentReject = nil;
return YES;
} else {
NSString *msg;
if ([authResult isError]) {
Expand All @@ -137,13 +141,15 @@ + (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
currentResolve = nil;
currentReject = nil;
}
return YES;
}
return NO;
}

+ (UIViewController*)topMostController
+ (UIViewController *)topMostController
{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topController
= [UIApplication sharedApplication].keyWindow.rootViewController;

while (topController.presentedViewController) {
topController = topController.presentedViewController;
Expand All @@ -154,10 +160,10 @@ + (UIViewController*)topMostController

+ (void)setAppKey {
NSString *appKey = [self getAppKey];
if (appKey != nil) {

if (appKey) {
[DBClientsManager setupWithAppKey:appKey];
}
}


@end

0 comments on commit 467452d

Please sign in to comment.