0

所以我正在开发一个接收后台事件的react-native APP。并且当手机被锁定时,当收到后台事件时,应用程序崩溃并且不会在领域库中保存数据。

是基于地理位置的APP,所以需要在手机锁定时(按iPhone上的阻止按钮时)保存信息。

尝试修改一些本机 Objective-c 代码,仅适用于 DEV 构建(调试构建),但不适用于生产构建。

本机代码上的代码

RLMRealm *realm = [RLMRealm defaultRealm];

// Get our Realm file's parent directory
NSString *folderPath = realm.configuration.fileURL.URLByDeletingLastPathComponent.path;

// Disable file protection for this directory
[[NSFileManager defaultManager] setAttributes:@{NSFileProtectionKey: NSFileProtectionNone}
                                 ofItemAtPath:folderPath error:nil];

手机锁定时,领域会保存数据。

4

0 回答 0