Closed madebydavid closed 3 years ago
Hi @madebydavid, Apologies for the difficulties you have been facing with getting these two libraries to work together. We'd be glad to assist.
1) In version 1.0.17
, a change has been made where AppDelegate swizzling is forced, making it impossible to override the AppDelegate
APNs methods in your AppDelegate.m
. Please downgrade to 1.0.16
to work around this, by running these commands:
npm install pushy-react-native@1.0.16 --save
react-native link pushy-react-native
cd ios && pod install
2) Edit Libraries/PushyRN.xcodeproj/PushyModule.h
, replacing it with the following:
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
@interface PushyModule : RCTEventEmitter <RCTBridgeModule>
+ (void)didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token;
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
@end
3) Edit Libraries/PushyRN.xcodeproj/PushyModule.m
, adding the following method inside:
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token {
[pushy application:[UIApplication sharedApplication] didRegisterForRemoteNotificationsWithDeviceToken:token];
}
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[pushy application:[UIApplication sharedApplication] didReceiveRemoteNotification:notification fetchCompletionHandler:completionHandler];
}
4) Add the following method overrides to your AppDelegate.m
(delete previous overrides for these two methods, if exist):
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Pass token to Firebase Auth
[[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeSandbox];
// Pass token to Pushy
[PushyModule didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)notification
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Pass to Firebase Auth
if ([[FIRAuth auth] canHandleNotification:notification]) {
completionHandler(UIBackgroundFetchResultNoData);
return;
}
// Pass notification to Pushy
[PushyModule didReceiveRemoteNotification: notification fetchCompletionHandler: completionHandler];
}
Run your app, and let us know if the auth/notification-not-forwarded
error goes away.
We are trying to get
pushy-react-native
to work along side@react-native-firebase/auth
.When calling
firebase.auth()
we would receive an error in the console:We attempted to resolve this by:
FirebaseAppDelegateProxyEnabled
toNO
inInfo.plist
PushyModule
code as described in this comment on issue #56toggleMethodSwizzling
no-longer existsHowever, we have not been successful.
Is there a guide or some notes on how to modify
AppDelegate.m
so that the current React Native version of Pushy can work with@react-native-firebase/auth
or are the two libraries currently incompatible? Many of the examples or comments we can find seem to be for older versions of the libraries.Many thanks!