Async-storage: Brown Field integration

Created on 14 Sep 2020  路  7Comments  路  Source: react-native-async-storage/async-storage

You want to:


I'm start to implementing a simple feature but got stuck on the iOS native side, I'm not an experienced iOS dev so bear with me on this.

What I need is a way on the native side read/write the Asyncstorage while keep the functionality on the React Native side (because the JS thread will be dead after the app is in the bg for a while)

Details:

What I've done:

  1. #import <RNCAsyncStorage/RNCAsyncStorage.h>
  2. in my native module, I have NSString *result = [[[RNCAsyncStorage alloc] init] _getValueForKey], but I got an error stating No visible @interface for 'RNCAsyncStorage' declares the selector '_getValueForKey'

Any idea how this should be implemented? Thanks!

All 7 comments

Hey @DevArenaCN

You can have a look at brownfield integration docs for iOS

Hey @DevArenaCN

You can have a look at brownfield integration docs for iOS

I've checked the brownfield doc, to my understanding even though I don't actually need to reinvent the wheels here, I'd still need to implement the delegate for every listed protocols, right?

Yes, that's correct

Gotcha, thanks for clearing that up for me.

Yes, that's correct

Another question, and it's been haunting me for a while now.?

 RNCAsyncStorage *asyncStorage = [bridge moduleForClass:[RNCAsyncStorage class]];
  asyncStorage.delegate = self;

I have there declared in my init for the delegate that I'm implementing, but I keep getting Use of undeclared identifier 'bridge'. I already imported RCTBridge, anything I did wrong?

Have a look at example app's AppDelegate

So I have get the example app locally and have it built and up and running, from the source code it seems like you could toggle the set/unset delegate via dev menu, however I didn't see it shown (cmd+d), should it be at another place?

Also, I've tried to set my delegate this way

 _testDelegate = [RNCTestAsyncStorageDelegate new];
  RNCAsyncStorage *asyncStorage = [bridge moduleForClass:[RNCAsyncStorage class]];
  asyncStorage.delegate = _testDelegate;

And it seems like the delegate wasn't set after all. Anything I did wrong?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

burhanahmed92 picture burhanahmed92  路  27Comments

while-it picture while-it  路  51Comments

dominiczaq picture dominiczaq  路  22Comments

srivatsav picture srivatsav  路  26Comments

cohawk picture cohawk  路  28Comments