Open sukantasamanta96 opened 5 months ago
Did you figure it out?
Hi @Saad-Bashar, I tried all the natatory steps which ate mentioned in the documents but failed to resolve this. I fix the issue with "@react-native-firebase/messaging" module.
I was able to hack this by giving some time to report the notification arrived, I added something like this in my AppDelegate:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
});
Any updates on this?
I would 2nd that you probably want to have some delay here. Here's mine.
(We happen to use Adobe's marketing cloud, so the notification response (pressed/dismissed) is tracked for marketing analytics purposes too.)
tl;dr, wrap in dispatch_async(dispatch_get_main_queue(), ^{ ... }
and you're probably good.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
dispatch_async(dispatch_get_main_queue(), ^{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
[AEPMobileMessaging handleNotificationResponse:response
urlHandler:^(NSURL *url) {
// Returns "false" for adobe assurance URLs and "true" for all other
// URLs.
//
// Here "false" means that the SDK will handle the URLs and "true"
// means that the host app will handle the URL.
return !([url.path containsString:@"adobeassurance"] ||
[url.scheme containsString:@"http"]);
}
closure:^(AEPPushTrackingStatus status) {
// we don't actually care about doing anything here
}];
completionHandler();
});
}
Please excuse the ugly formatting. I use clang-format -i --sort-includes=0 --style=LLVM
and apparently this is what it does.
I am trying to set up the push notification for iOS for React Native version 0.71.7. I have done all the setup for this push notification which is mentioned in your git repository. Push notification was working fine for my old version of project 0.67.2. But in this new version, it is not working. Please help me out to solve this problem.
Mechine Configaration :- Mac Os Version:- 14.4.1 Xcode Version:- 15.3 Node Version:- v20.12.0 RN Version:- 0.71.7
Sample code base which i am using in the index.js import { SafeAreaView, Text, View } from 'react-native'; import React, { Component } from 'react'; import PushNotificationIOS from "@react-native-community/push-notification-ios"; import PushNotification from "react-native-push-notification"; export default class App extends Component { constructor(props) { super(props); this.state = { deviceToken: "" }; }
componentDidMount() { this._getToken(); const type = 'notification'; PushNotificationIOS.addEventListener(type, this.onRemoteNotification); return () => { PushNotificationIOS.removeEventListener(type); }; }
onRemoteNotification = (notification) => { const isClicked = notification.getData().userInteraction === 1; if (isClicked) { // Navigate user to another screen } else { // Do something else with push notification } // Use the appropriate result based on what you needed to do for this notification const result = PushNotificationIOS.FetchResult.NoData; notification.finish(result); };
// get RCM token for push notification _getToken = () => { let that = this;
};
render() { return ( <SafeAreaView style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> <Text style={{ fontSize: 20 }}>App ) } }
I am sharing the reference screenshots.
Please help me to solve this problem i have been suffering from this problem for a long time after upgrading the React native project version.