Skip to content
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

fix: api kay change clean (no more crash) #4

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ios/BundleUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
#else
#import <React/RCTBridgeModule.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface BundleUpdater : NSObject <RCTBridgeModule, UIViewControllerTransitioningDelegate>
@property (nonatomic, weak) RCTBridge *bridge;

+ (instancetype)sharedInstance;
- (void)initialization:(NSString *)apiKey
resolve:(void (^)(NSString *))resolve
reject:(void (^)(NSString *, NSString *, NSError *))reject;
- (NSURL *)initializeBundle:(RCTBridge *)bridge withKey:(NSString *)key;
- (void)reload;
- (void)checkAndReplaceBundle: (nullable NSString *)apiKey;
NS_ASSUME_NONNULL_END

#endif

@end
10 changes: 4 additions & 6 deletions ios/BundleUpdater.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#import "BundleUpdaterBottomSheetViewController.h"

#import "CommonCrypto/CommonDigest.h"
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>
#import <sys/utsname.h>
#import <React/RCTBundleURLProvider.h>
Expand All @@ -22,8 +21,6 @@ @implementation BundleUpdater{
NSString *_bundle_id_from_api;
BundleUpdaterBottomSheetViewController *_bottomSheetVC;
}
@synthesize bridge = _bridge;

RCT_EXPORT_MODULE()

+ (instancetype)sharedInstance{
Expand All @@ -38,7 +35,7 @@ + (instancetype)sharedInstance{
- (instancetype)init{
self = [super init];
// init variables
_apiUrl = @"http://192.168.0.102:3003";
_apiUrl = @"http://192.168.1.92:3003";
_bundle_id_from_api = @"";
_bottomSheetVC = [[BundleUpdaterBottomSheetViewController alloc] init];
return self;
Expand Down Expand Up @@ -210,8 +207,8 @@ -(void)hideBottomSheet {
* @param apiKey - the apiKey for the app
*/
- (void)initialization:(NSString *)apiKey
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject {
resolve:(void (^)(NSString *))resolve
reject:(void (^)(NSString *, NSString *, NSError *))reject {
// TODO fix Conflicting parameter types in implementation of
// 'initialization:resolve:reject:': 'void (^__strong)(NSString *__strong)'
// vs '__strong RCTPromiseResolveBlock' (aka 'void (^__strong)(__strong
Expand Down Expand Up @@ -347,6 +344,7 @@ - (NSURL *)initializeBundle:(RCTBridge *)bridge withKey:(NSString *)key{
[[NSFileManager defaultManager] removeItemAtPath:documentDirectoryJSBundleFilePath error:nil];
}
[[NSUserDefaults standardUserDefaults] setObject:key forKey:@"bundleKey"];
[[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"bundleId"];
}
// Check if there is the main.jsbundle file in the Document directory
NSString *documentDirectoryJSBundleFilePath =
Expand Down
Loading