Skip to content

Commit

Permalink
Refactor sourceURLForBridge and didFinishLaunchingWithOptions methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Mar 12, 2024
1 parent 6f165f1 commit 0aafdf4
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions site/pages/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,31 +139,17 @@ date +%s > "$DEST/pushy_build_time.txt"
// #endif


// 如果RN版本 >= 0.59,修改sourceURLForBridge
// 修改sourceURLForBridge方法
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
// 原先这里的写法继续保留(所以debug模式下不可热更新)
return .....
// 原先DEBUG这里的写法不作修改(所以DEBUG模式下不可热更新)
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
 // 把这里非DEBUG的情况替换为热更新bundle的写法
return [RCTPushy bundleURL];
return [RCTPushy bundleURL]; // <-- 把这里非DEBUG的情况替换为热更新bundle
#endif
}

// 如果RN版本 < 0.59,修改didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#if DEBUG
 // 原来的jsCodeLocation保留在这里(所以debug模式下不可热更新)
 jsCodeLocation = ..........
#else
 // 把这里非DEBUG的情况替换为热更新bundle的写法
 jsCodeLocation = [RCTPushy bundleURL];
#endif
// ... 其它代码
}

```

#### Android
Expand Down

0 comments on commit 0aafdf4

Please sign in to comment.