React-native-fcm: TypeError: Cannot set property 'finish' of undefined

Created on 9 Feb 2017  路  6Comments  路  Source: evollu/react-native-fcm

Hi!
I'm using lib with version 6.0.2 and RN 0.40.
iOS 9.3.5, app running in foreground
My PushController.js is the same as in the example

When i receive notification in iOS,
i have a trouble with FCM.on = (event, callback) => {} at index.js file.

there is a message in logs
Possible Unhandled Promise Rejection (id: 0): Cannot set property 'finish' of undefined TypeError: Cannot set property 'finish' of undefined

in logs i have two runnings of this method

if(event === FCMEvent.Notification){
return DeviceEventEmitter.addListener(event, async(data)=>{
console.log('EVENT', event)
console.log('DATA', data)
data.finish = finish; // <== trouble in this line(receive only yellow box at the bottom of screen)
try{
await callback(data);
} catch(err){
console.error('Notification handler err', err)
throw err;
}
if(!data._finishCalled){
data.finish();
}
})
}
p.s sorry for this code formatting, i don't know how code-paste works)))))

in screenshots, you can see that DATA in first log has some object,
but at the second time it is undefined (i have send one push notification from server)

i don't have any ideas about this=(

thanks!

2017-02-09 17 49 33
2017-02-09 17 49 47

Most helpful comment

good catch. fixed in v6.0.3

All 6 comments

By the way, I get undefined INITIAL NOTIFICATION in iOS device

some upd:
when ios device disconnected from pc, push notifications work as well and so i have a question, why in ios version when triggers method FCM.on(),
DeviceEventEmitter.addListener(event, async(data)=> {} has parameter data == undefined
anybody have any ideas?
thanks a lot

i think that i've found a bug, @evollu can u look at this?

  • (void)didReceiveLocalNotification:(UILocalNotification )notification {
    NSMutableDictionary
    data = [[NSMutableDictionary alloc] initWithDictionary: notification.userInfo];
    [data setValue:@"local_notification" forKey:@"_notificationType"];
    [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:@{@"data": data}];
    }

i changed userInfo parameter at RNFIRMessaging.m from data to @{@"data": data} and notifications in ios version have been working correct now

let me check

good catch. fixed in v6.0.3

thanks=)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xavieramoros picture xavieramoros  路  4Comments

jitenderchand1 picture jitenderchand1  路  4Comments

sf577 picture sf577  路  3Comments

gplopes picture gplopes  路  6Comments

404sand808s picture 404sand808s  路  5Comments