@@ -16,8 +16,8 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
1616- (void )handleMethodCall : (FlutterMethodCall *)call
1717 result : (FlutterResult)result {
1818 if ([call.method isEqualToString: @" getAll" ]) {
19- NSDate *installDate = [self getInstallDate ];
20- NSDate *updateDate = [self getUpdateDate ];
19+ NSString *installDateStr = [self getTimeMillisStringFromDate: [ self getInstallDate ] ];
20+ NSString *updateDateStr = [self getTimeMillisStringFromDate: [ self getUpdateDate ] ];
2121
2222 result (@{
2323 @" appName" : [[NSBundle mainBundle ]
@@ -33,15 +33,19 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
3333 objectForInfoDictionaryKey: @" CFBundleVersion" ]
3434 ?: [NSNull null ],
3535 @" installerStore" : [NSNull null ],
36- @" installTime" : [ self getTimeMillisStringFromDate: installDate] ?: [NSNull null ],
37- @" updateTime" : [ self getTimeMillisStringFromDate: updateDate] ?: [NSNull null ]
36+ @" installTime" : installDateStr ?: updateDateStr ?: [NSNull null ],
37+ @" updateTime" : updateDateStr ?: [NSNull null ]
3838 });
3939 } else {
4040 result (FlutterMethodNotImplemented);
4141 }
4242}
4343
4444- (NSDate *)getInstallDate {
45+ if (![self isRunningInSandbox ]) {
46+ return nil ;
47+ }
48+
4549 NSURL * urlToDocumentsFolder = [[[NSFileManager defaultManager ] URLsForDirectory: NSDocumentDirectory inDomains: NSUserDomainMask] lastObject ];
4650 __autoreleasing NSError *error;
4751 NSDictionary *attributes = [[NSFileManager defaultManager ] attributesOfItemAtPath: urlToDocumentsFolder.path error: &error];
@@ -74,4 +78,9 @@ - (NSString *)getTimeMillisStringFromDate:(NSDate *)date {
7478 return [timeMillis stringValue ];
7579}
7680
81+ - (BOOL )isRunningInSandbox {
82+ NSString *sandboxContainerId = [[[NSProcessInfo processInfo ] environment ] objectForKey: @" APP_SANDBOX_CONTAINER_ID" ];
83+ return sandboxContainerId != nil ;
84+ }
85+
7786@end
0 commit comments