question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'RefreshToken' of undefined

See original GitHub issue

Hi, I got exception as soon as I added the FCM SDK and get it launched.

Versions: “react-native-fcm”: “^2.5.6”, “react-native”: “0.39.2”,

Device: ios 10.3 emulator

X Code

// ADDED
[FIRApp configure];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];


// ADDED

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo];
  if([[notification.request.content.userInfo valueForKey:@"show_in_foreground"] isEqual:@YES]){
    completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
  }else{
    completionHandler(UNNotificationPresentationOptionNone);
  }
  
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler
{
  NSDictionary* userInfo = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo];
  [userInfo setValue:@YES forKey:@"opened_from_tray"];
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];
}

//You can skip this method if you don't want to use local notification
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];
  completionHandler(UIBackgroundFetchResultNoData);
}

JS Code:


componentDidMount() {
  // push Notification
  FCM.requestPermissions(); // for iOS
  FCM.getFCMToken().then(token => {
    console.log('>>>> get FCM token:', token);
  });

  refreshTokenListener = FCM.on(FCMEvent.RefreshToken, (token) => {
    console.log('>>>> refreshTokenListener FCM token:', token);
  });

  notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
    
  });
}

// ERRORS ExceptionsManager.js:63 Cannot read property ‘RefreshToken’ of undefined Unhandled JS Exception: Cannot read property ‘RefreshToken’ of undefined

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
daywong1119commented, Apr 20, 2017

@MaxToyberman Great! It works well after replacing with refreshToken . Thanks

0reactions
PoojaVMcommented, Mar 29, 2018

Getting the same issue. Anyone got any solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'then' of undefined when using JWT ...
Sorry I'm new to backend (nodejs) and I'm trying to build a JWT token and refresh token but I stumbled across an error...
Read more >
Refresh token gives "Cannot read property 'scope' of undefined"
The first error seems like there is something wrong with the request, and the second error looks like the application is not authorized...
Read more >
cannot read property 'token' of undefined react
The error generally means that something went wrong when the tool makes the authentication call - it is looking for the token and...
Read more >
cannot read properties of undefined (reading 'refresh') - You.com
To solve the "Cannot read properties of undefined" error, make sure to insert the JS script tag at the bottom of the body....
Read more >
ERROR TypeError: Cannot read property 'token' of undefined ...
I and trying to build an using a php API, I have been able to login, but when I tried to access other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found