Git Product home page Git Product logo

Comments (7)

CodeByTarun avatar CodeByTarun commented on June 1, 2024 1

Hey, you need to use an app group in order to get it working, see the following:

https://github.com/mrousavy/react-native-mmkv#app-groups
https://github.com/Tencent/MMKV/wiki/iOS_tutorial#configuration (the multi-process accessing part)

from react-native-mmkv.

pavelustenko avatar pavelustenko commented on June 1, 2024

@CodeByTarun
Still no luck.
I created app group, added my app and notification service to it, changed both initialization calls in AppDelegate.m and NotificationService.m to

  NSString *myGroupID = @"group.com.ttyxx";
  // the group dir that can be accessed by App & extensions
  NSString *groupDir = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:myGroupID].path;
  [MMKV initializeMMKV:nil groupDir:groupDir logLevel:MMKVLogInfo];

I also added following code to AppDelegate.m to be sure I could read this property from JS layer.

  [mmkv setString:@"\"HELLO\"" forKey:@"string"];

It works.

But still no luck with Notification service

NSString *value = [mmkv getStringForKey:@"string"];
    NSLog(@"MMKV VALUE IS: %@", value);

value is still return nil.

NSArray *keys = [mmkv allKeys];

keys has 0 elements

from react-native-mmkv.

pavelustenko avatar pavelustenko commented on June 1, 2024

I changed Debug MMKV's log level to MMKVLogDebug
Both processes log the same folder
AppDelegate Log:

[I] <libMMKV.mm:132::+[MMKV initializeMMKV:groupDir:logLevel:]> groupDir: /private/var/mobile/Containers/Shared/AppGroup/9513AAB0-195C-4AF1-9C44-576A77E86427/mmkv

NotificationService Log:

[I] <libMMKV.mm:132::+[MMKV initializeMMKV:groupDir:logLevel:]> groupDir: /private/var/mobile/Containers/Shared/AppGroup/9513AAB0-195C-4AF1-9C44-576A77E86427/mmkv

Obviously the folder is the same. I have no clue what to do next.

from react-native-mmkv.

mrousavy avatar mrousavy commented on June 1, 2024

Weird, I think AppGroups are supposed to make that work. Maybe create an issue in the native MMKV repo if this is actually an actual MMKV bug?

from react-native-mmkv.

mrousavy avatar mrousavy commented on June 1, 2024

Did you add AppGroup to Info.plist?

NSString* appGroup = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"];
if (appGroup == nil) {
[MMKV initializeMMKV:storageDirectory];
} else {
NSString* groupDir = [[NSFileManager defaultManager]
containerURLForSecurityApplicationGroupIdentifier:appGroup]
.path;
[MMKV initializeMMKV:nil groupDir:groupDir logLevel:MMKVLogNone];
}

from react-native-mmkv.

mrousavy avatar mrousavy commented on June 1, 2024

I think this is a duplicate of #622

from react-native-mmkv.

pavelustenko avatar pavelustenko commented on June 1, 2024

@mrousavy

Did you add AppGroup to Info.plist?

Yes I did.

I think this is a duplicate of #622

Thank you for your tip, I'll check it.

from react-native-mmkv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.