Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App getting crash when clicking on push notification send from webengage dashboard #49

Closed
chaitanya71998 opened this issue Jul 11, 2023 · 1 comment

Comments

@chaitanya71998
Copy link

chaitanya71998 commented Jul 11, 2023

Hi,

I am using webengage for my react native app push notifications. After following the reference provided in the webengage and react native webengage docs, I am able to get push notifications in my app. i am doing simple push notification integration,with not additional configrurations.

But after clicking on push notification my app is getting crashed and i observered below log in the console.

023-07-11 17:21:02.851991+0530 Bytes[413:28518] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSObject userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:]: unrecognized selector sent to instance 0x280955400'

these are the following changes i had done for integration:

// Appdelegate.mm
#import "AppDelegate.h"
#import <WebEngage/WebEngage.h>
#import <React/RCTBundleURLProvider.h>
#import <Firebase.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"Bytes";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};
    [FIRApp configure];
    
    // Enable Firebase Analytics
    [FIRAnalytics setAnalyticsCollectionEnabled:YES];
    [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
  return true;
}
@end
// pod file
target 'Bytes' do
  config = use_native_modules!
  # Add the WebEngage pod
  pod 'react-native-webengage', :path => '../node_modules/react-native-webengage'
// usage in react native code
import WebEngage from 'react-native-webengage'

export const webengage = new WebEngage()

webengage.push.onClick(function (notificationData: { [x: string]: any }) {
      const { byteId } = webengageNotificationDataKeys
      const notificationByteId = notificationData[byteId]
      }))

I was not sure why is this happened. Is there any additonal configuration i has to do apart from these?
Also is this the way for ios push notificaiton as well to get data from notification data?

reference followed:
react native integration: https://docs.webengage.com/docs/react-native, https://github.com/WebEngage/react-native-webengage
webengage installation : https://docs.webengage.com/docs/ios-getting-started

output of react-native info:
System:
OS: macOS 12.6.5
CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
Memory: 18.22 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 16.4.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.6.0 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 13.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.7 => 0.71.7
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

TIA

@chaitanya71998
Copy link
Author

#51 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant