alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
762 stars 397 forks source link

Transparent Modal #188

Closed Epiczzor closed 4 years ago

Epiczzor commented 4 years ago

Hey, I'm trying to set this up on 0.61, everything works fine but my share page does not load my react native code, it shows me a transparent page that slides up and I am able to close it, I am using separated bundles configuration. The name of my JS file that has the view code is ShareModule, the AppRegistry is set up on that page

This is my ShareSong.m ( MyShareEx.m)

//
//  ShareSong.m
//  ShareSong
//
//  Created by Sahil Singh on 03/11/19.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>

@interface ShareSong : ReactNativeShareExtension
@end

@implementation ShareSong

RCT_EXPORT_MODULE();

- (UIView*) shareView {
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"ShareModule" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"ShareSong"
                                               initialProperties:nil
                                                   launchOptions:nil];

  // Uncomment for console output in Xcode console for release mode on device:
  // RCTSetLogThreshold(RCTLogLevelInfo - 1);

  return rootView;
}

@end

also I get this warning IMG_6950

Epiczzor commented 4 years ago

Update: It doesn't work in the simulator as well

Also i had trouble doing this part of the guide - App and app extension bundles

I got an error when i added lines in app target's "Bundle React Native code and images" phase

export NODE_BINARY=node
../bin/react-native-xcode.sh

In the share extension "Bundle React Native code and images" did not exist

Followed the steps on this issue: #182

Epiczzor commented 4 years ago

Hey guys, turns out my issue was with Firebase, i didnt know how to check logs before but i realised i had to select share song as target instead of my app and then build. after further investigation of the log i realised that FIrebase was crashing the extension because it wasnt initialized. so i added the Initialization code and google services plist inside the Extension folder, and it worked !