react-native-voip-push-notification
react-native-voip-push-notification copied to clipboard
Fixed bug preventing delayed events from working
When using [RNVoipPushNotificationManager voipRegistration];
in AppDelegate.m
the RNVoipPushNotificationManager.m
constructor (or init function or whatever Objective-C calls this), is executed twice, once I suppose by us interacting with RNVoipPushNotificationManager prior to the RN Bridge having instantiated it, and then again later when the bridge is going to use it and start observing.
The initialization process is a bit of a mystery to me, but in any regard, the _delayedEvents
array is overridden by the 2nd initialization, causing us to loose all the delayed events, effectively causing didLoadWithEvents
to never fire, and the events being lost in the void that exists between IOS and React Native :(
This fixes that, but as I'm not really an objective-c developer, I don't know if I'm just hacking this together, instead of addressing some underlaying issue.
Will do, just give me few days more.
@danjenkins you guys also observed this issue?
@zxcpoiu @jonastelzio is a client of mine and I worked through the issue with him - a) I can't see any harm from the change and b) seems to fix the issues we were facing :) I just requested your review as I know Github is noisy :D
I did some tests but can't reproduce the issue. Didn't see any duplicated logs.
@jonastelzio Do you see each log twice?
- (instancetype)init
{
NSLog(@"DEBUG [RNVoipPushNotification][init] ENTER");
if (self = [super init]) {
NSLog(@"DEBUG [RNVoipPushNotification][init] INITIALIZE");
_delayedEvents = [NSMutableArray array];
}
return self;
}
// --- I only saw these logs once:
//DEBUG [RNVoipPushNotification][init] ENTER
//DEBUG [RNVoipPushNotification][init] INITIALIZE
It is really strange the instance be initialized twice. Although it won't hurt to merge this, and can be merged for sure.
But if you have this duplicate initialization issue, then react-native-callkeep would be affected as well. (and likely the other modules)
Not sure what is the root cause.
@manuquentin pardon me to ping you, but do you have any idea?
@thymikee Seems you have the same issue, do you have any clues?
But if you have this duplicate initialization issue, then react-native-callkeep would be affected as well. (and likely the other modules)
Not sure what is the root cause.
Indeed and it is! I've made the exact same patch in that repo, but yeah I don't fully understand why it's necessary either, but my insight into Objective-C isn't quite deep enough to speculate.
I'll run the debugging code monday for good measure. I keep my macbook at the office so have no way to run it at home.
I can confirm that init is called twice. I have added some more logs and my output is the following:
Also I had a problem that startObserving not called on application metro bundler restart.
please take a look at #87 and test if that solves this problem :)
This may be solved by #87, reopen if there is still issues