Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Config no fetch Data #1161

Closed
t-kabaya opened this issue May 31, 2018 · 0 comments
Closed

Remote Config no fetch Data #1161

t-kabaya opened this issue May 31, 2018 · 0 comments

Comments

@t-kabaya
Copy link

t-kabaya commented May 31, 2018

Thank you for this great library. I can't fetch my parameter which setup on my Firebase. I am pretty sure I have setup the RemoteConfig SDK and my config parameter on my Firebase. Does anyone encounter this problem?

// App Deligate.m
#import "AppDelegate.h"
@import FirebaseCore;
@import FirebaseMessaging;
#import "RNFirebaseMessaging.h"
#import "RNFirebaseNotifications.h"

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLinkingManager.h>
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"clintal"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];

  [RNSentry installWithRootView:rootView];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  [FIRApp configure];
  [RNFirebaseNotifications configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
  
  return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  return [RCTLinkingManager application:application openURL:url
                      sourceApplication:sourceApplication annotation:annotation];
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];
}

@end
// Saga
import Firebase from 'react-native-firebase'

export function * fetchRemoteConfig () {
  try {
    const config = yield Firebase.config()
    yield config.enableDeveloperMode()
    yield config.setDefaults({
      clintalTitle: 'NullTitle',
      clintalImage: 'NullImage'
    })
    console.tron.log('setteddefault')

    const keys = ['clintalTitle', 'clintalImage']
    yield config
      .fetch(0)
      .then(() => config.activateFetched())
      .thsn(activated => {
        if (!activated) console.tron.log('remoteConfig data not activated')
        console.tron.log('remoteConfig data not activated')
        return config.getValues(keys)
      })
      .then(datas => {
        console.tron.log('Sucesssss')
        const clintalTitle = datas.clintalTitle.val()
        const clintalImage = datas.clintalImage.val()
        console.tron.log(clintalImage)
        console.tron.log(clintalTitle)
      })
      .catch(e => console.tron.log(e))
  } catch (e) {
    console.tron.log(e)
  }
}

Reactotron shows
'setteddefault'
'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false'

Application Target Platform: iOS
Development Operating System: macOS High Sierra
React Native version: "^0.53.3",
RNFirebase Version: git+https://github.com/invertase/react-native-firebase.git#c1abfcf0028eb0eb64176388b2e9b2e9cd77414c"
Firebase Module: remote config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant