1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 10:21:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

improve iOS reload handling

This commit is contained in:
sunnylqm
2025-06-28 21:40:06 +08:00
parent 6a0a5b2d49
commit d7b5562ab7
2 changed files with 15 additions and 15 deletions

View File

@@ -315,16 +315,15 @@ RCT_EXPORT_METHOD(reloadUpdate:(NSDictionary *)options
if (hash.length) { if (hash.length) {
// 只在 setNeedUpdate 成功后 resolve // 只在 setNeedUpdate 成功后 resolve
[self setNeedUpdate:options resolver:^(id result) { [self setNeedUpdate:options resolver:^(id result) {
// reload in earlier version
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.bridge setValue:[[self class] bundleURL] forKey:@"bundleURL"];
[self.bridge reload];
});
#if __has_include("RCTReloadCommand.h") #if __has_include("RCTReloadCommand.h")
// reload 0.62+ // reload 0.62+
RCTReloadCommandSetBundleURL([[self class] bundleURL]); RCTReloadCommandSetBundleURL([[self class] bundleURL]);
RCTTriggerReloadCommandListeners(@"pushy reload"); RCTTriggerReloadCommandListeners(@"pushy reloadUpdate");
#else
[self.bridge reload];
#endif #endif
});
resolve(@true); resolve(@true);
} rejecter:^(NSString *code, NSString *message, NSError *error) { } rejecter:^(NSString *code, NSString *message, NSError *error) {
reject(code, message, error); reject(code, message, error);
@@ -343,13 +342,14 @@ RCT_EXPORT_METHOD(restartApp:(RCTPromiseResolveBlock)resolve
{ {
@try { @try {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.bridge reload];
});
#if __has_include("RCTReloadCommand.h") #if __has_include("RCTReloadCommand.h")
// reload 0.62+ // reload 0.62+
RCTReloadCommandSetBundleURL([[self class] bundleURL]); RCTReloadCommandSetBundleURL([[self class] bundleURL]);
RCTTriggerReloadCommandListeners(@"pushy restartApp"); RCTTriggerReloadCommandListeners(@"pushy restartApp");
#else
[self.bridge reload];
#endif #endif
});
resolve(@true); resolve(@true);
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.29.5", "version": "10.29.6",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {