Skip to content

Commit

Permalink
fix openning url from widget
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkriz committed Dec 28, 2017
1 parent cfe1256 commit f99eaab
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
72 changes: 36 additions & 36 deletions Examples/Complex/ios/HoppyGoWidget.xcodeproj/project.pbxproj
Expand Up @@ -22,7 +22,6 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
286A0960DAF048788F6A7258 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AE27B85176134A628597A142 /* libRCTActionSheet.a */; };
2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
Expand All @@ -35,9 +34,9 @@
2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; };
2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
2DCD954D1E0B4F2C00145EB5 /* HoppyGoWidgetTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* HoppyGoWidgetTests.m */; };
572E4FCC1FF52AED00345602 /* libRNFetchBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 572E4FCA1FF52A3F00345602 /* libRNFetchBlob.a */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
A5A65B9D9CD44E3789804C08 /* libRNFetchBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A767B424B9D749409BF599D1 /* libRNFetchBlob.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
DB105A442EB65120E1BEC50D /* TodayWidgetExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = C11A802C9EFE7921E6DE145D /* TodayWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -211,6 +210,13 @@
remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4;
remoteInfo = "jschelpers-tvOS";
};
572E4FC91FF52A3F00345602 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2E033C5AB71741D7AEDEF89B /* RNFetchBlob.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A15C300E1CD25C330074CB35;
remoteInfo = RNFetchBlob;
};
578A0FAA1FC194D1003ED0F9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */;
Expand Down Expand Up @@ -274,13 +280,6 @@
remoteGlobalIDString = 9936F32F1F5F2E5B0010BF04;
remoteInfo = "privatedata-tvOS";
};
57AEA3D91FD1E0B100C56764 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8BC72E37F6C24A969D734EE6 /* RNFetchBlob.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A15C300E1CD25C330074CB35;
remoteInfo = RNFetchBlob;
};
5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */;
Expand Down Expand Up @@ -361,12 +360,12 @@
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
2D02E47B1E0B4A5D006451C7 /* HoppyGoWidget-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HoppyGoWidget-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* HoppyGoWidget-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "HoppyGoWidget-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
2E033C5AB71741D7AEDEF89B /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; };
47A67ECF7A2B4006851C2DD4 /* libRNFetchBlob.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFetchBlob.a; sourceTree = "<group>"; };
5D64D823219D409FB7635F75 /* RNTodayWidgetExtension.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNTodayWidgetExtension.xcodeproj; path = "../node_modules/react-native-today-widget/ios/RNTodayWidgetExtension.xcodeproj"; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
8BC72E37F6C24A969D734EE6 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; };
A767B424B9D749409BF599D1 /* libRNFetchBlob.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFetchBlob.a; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
AE27B85176134A628597A142 /* libRCTActionSheet.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTActionSheet.a; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -384,6 +383,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
572E4FCC1FF52AED00345602 /* libRNFetchBlob.a in Frameworks */,
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */,
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
Expand All @@ -397,8 +397,6 @@
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
286A0960DAF048788F6A7258 /* libRCTActionSheet.a in Frameworks */,
A5A65B9D9CD44E3789804C08 /* libRNFetchBlob.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -541,21 +539,28 @@
name = Products;
sourceTree = "<group>";
};
578A0FD81FC1983C003ED0F9 /* Recovered References */ = {
572E4FA31FF52A3F00345602 /* Products */ = {
isa = PBXGroup;
children = (
AE27B85176134A628597A142 /* libRCTActionSheet.a */,
A767B424B9D749409BF599D1 /* libRNFetchBlob.a */,
572E4FCA1FF52A3F00345602 /* libRNFetchBlob.a */,
);
name = "Recovered References";
name = Products;
sourceTree = "<group>";
};
57AEA3D61FD1E0B100C56764 /* Products */ = {
572E4FCB1FF52AED00345602 /* Frameworks */ = {
isa = PBXGroup;
children = (
57AEA3DA1FD1E0B100C56764 /* libRNFetchBlob.a */,
);
name = Products;
name = Frameworks;
sourceTree = "<group>";
};
578A0FD81FC1983C003ED0F9 /* Recovered References */ = {
isa = PBXGroup;
children = (
AE27B85176134A628597A142 /* libRCTActionSheet.a */,
47A67ECF7A2B4006851C2DD4 /* libRNFetchBlob.a */,
);
name = "Recovered References";
sourceTree = "<group>";
};
5E91572E1DD0AC6500FF2AA8 /* Products */ = {
Expand Down Expand Up @@ -592,7 +597,7 @@
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
5D64D823219D409FB7635F75 /* RNTodayWidgetExtension.xcodeproj */,
8BC72E37F6C24A969D734EE6 /* RNFetchBlob.xcodeproj */,
2E033C5AB71741D7AEDEF89B /* RNFetchBlob.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
Expand All @@ -614,6 +619,7 @@
00E356EF1AD99517003FC87E /* HoppyGoWidgetTests */,
83CBBA001A601CBA00E9B192 /* Products */,
578A0FD81FC1983C003ED0F9 /* Recovered References */,
572E4FCB1FF52AED00345602 /* Frameworks */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand Down Expand Up @@ -819,8 +825,8 @@
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = 57AEA3D61FD1E0B100C56764 /* Products */;
ProjectRef = 8BC72E37F6C24A969D734EE6 /* RNFetchBlob.xcodeproj */;
ProductGroup = 572E4FA31FF52A3F00345602 /* Products */;
ProjectRef = 2E033C5AB71741D7AEDEF89B /* RNFetchBlob.xcodeproj */;
},
{
ProductGroup = F52B3DC7F2F87389F8B44908 /* Products */;
Expand Down Expand Up @@ -985,6 +991,13 @@
remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
572E4FCA1FF52A3F00345602 /* libRNFetchBlob.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNFetchBlob.a;
remoteRef = 572E4FC91FF52A3F00345602 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
578A0FAB1FC194D1003ED0F9 /* libRCTBlob-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down Expand Up @@ -1048,13 +1061,6 @@
remoteRef = 578A10061FC1983D003ED0F9 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
57AEA3DA1FD1E0B100C56764 /* libRNFetchBlob.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNFetchBlob.a;
remoteRef = 57AEA3D91FD1E0B100C56764 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down Expand Up @@ -1252,7 +1258,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1280,7 +1285,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1362,7 +1366,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1398,7 +1401,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = (
"-ObjC",
Expand Down Expand Up @@ -1428,7 +1430,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.HoppyGoWidget-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1454,7 +1455,6 @@
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.HoppyGoWidget-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
3 changes: 1 addition & 2 deletions ios/TodayWidgetExtension/Linking.h
Expand Up @@ -11,7 +11,6 @@

@interface Linking : NSObject <RCTBridgeModule>

- (void)openURL:(NSURL *)URL
completionHandler:(void (^)(BOOL success))completionHandler;
- (id)initWithContext:(NSExtensionContext*)context;

@end
12 changes: 5 additions & 7 deletions ios/TodayWidgetExtension/Linking.m
Expand Up @@ -13,22 +13,20 @@

@implementation Linking

NSExtensionContext* widgetContext;

NSExtensionContext* extensionContext;

// To export a module named DisplayMode
// To export a module named Linking
RCT_EXPORT_MODULE();

- (id)initWithContext:(NSExtensionContext*)context {
self = [super init];
extensionContext = context;
widgetContext = context;
return self;
}

RCT_EXPORT_METHOD(openURL:(NSURL *)URL
completionHandler:(void (^)(BOOL success))completionHandler)
RCT_EXPORT_METHOD(openURL:(NSURL *)url )
{
[extensionContext openURL:URL];
[widgetContext openURL:url completionHandler:nil];
}

@end
9 changes: 7 additions & 2 deletions lib/index.js
Expand Up @@ -4,8 +4,13 @@ import DevMenuComponent from './DevMenu';

export const DevMenu = DevMenuComponent;

export const setExpandable = (expandable: boolean = true, maxHeight: number = 110) => {
NativeModules.DisplayMode.setExpandable(expandable, maxHeight);
export const setExpandable = (
expandable: boolean = true,
maxHeight: number = 110,
) => {
if (NativeModules && NativeModules.DisplayMode) {
NativeModules.DisplayMode.setExpandable(expandable, maxHeight);
}
};

export const openURL = (url: string) => {
Expand Down

0 comments on commit f99eaab

Please sign in to comment.