Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

SOS: iOS Compatibility Issue with React Native New Architecture – JPush Integration Fails #38

@zhuiye

Description

@zhuiye

I am currently working on adapting the jpush-react-native plugin to the React Native New Architecture.
The Android side has already been successfully migrated, but I'm encountering issues on iOS when using the New Architecture.

New Architecture in RCTJushModule.mm

  RCT_EXPORT_METHOD(setupWithConfig:(NSDictionary *)params)
{
    if (params[@"appKey"] && params[@"channel"] && params[@"production"]) {
           // JPush初始化配置
           NSMutableDictionary *launchOptions = [NSMutableDictionary dictionaryWithDictionary:self.bridge.launchOptions];
           [JPUSHService setupWithOption:launchOptions appKey:params[@"appKey"]
                                 channel:params[@"channel"] apsForProduction:[params[@"production"] boolValue]];

           dispatch_async(dispatch_get_main_queue(), ^{
               // APNS
               JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
               if (@available(iOS 12.0, *)) {
                 entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings;
               }

              /*xcode ERRO show */
               [JPUSHService registerForRemoteNotificationConfig:entity delegate:[[UIApplication sharedApplication] delegate]];

               [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
              
               NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
               [defaultCenter addObserver:[[UIApplication sharedApplication] delegate] selector:@selector(networkDidReceiveMessage:) name:kJPFNetworkDidReceiveMessageNotification object:nil];
               // 地理围栏
               [JPUSHService registerLbsGeofenceDelegate:[[UIApplication sharedApplication] delegate] withLaunchOptions:launchOptions];
               // 应用内消息
               [JPUSHService setInAppMessageDelegate:self];
           });

           NSMutableArray *notificationList = [RCTJPushEventQueue sharedInstance]._notificationQueue;
           if(notificationList.count) {
               [self sendApnsNotificationEventByDictionary:notificationList[0]];
           }
           NSMutableArray *localNotificationList = [RCTJPushEventQueue sharedInstance]._localNotificationQueue;
           if(localNotificationList.count) {
               [self sendLocalNotificationEventByDictionary:localNotificationList[0]];
           }
       }
}
     

xcode error

Cannot initialize a parameter of type 'id<JPUSHRegisterDelegate> _Nullable' with an rvalue of type 'id<UIApplicationDelegate> _Nullable'

I asked AI for help, and it suggested some solutions, such as force casting, like:

id<JPUSHRegisterDelegate> jpushDelegate = (id<JPUSHRegisterDelegate>)[UIApplication sharedApplication].delegate;
[JPUSHService registerForRemoteNotificationConfig:entity delegate:jpushDelegate];

that is ok,xcode pass, but run app ,call setupWithConfig method , the app cashed.

Error: JPushModule.setupWithConfig raised an exception: -[RCTJPushModule bridge]: unrecognized selector sent to instance 0x600000053600

🆘 Request for Help

Due to my limited knowledge of iOS native development and the React Native New Architecture internals, I’m unsure how to proceed.

Could you please advise me on:

  • ✅ How to correctly register JPush delegates?
  • ✅ How to ensure push and message callbacks work as expected?
  • ✅ How to ensure compatibility with both the old and new architectures?

Additional Notes:

  1. This library compiles and runs fine under the Old Architecture.
  2. My AppDelegate correctly implements the JPUSHRegisterDelegate protocol.

If you have some time, please take a look at the forked branch I’m working on:
🔗 https://github.com/zhuiye/jpush-react-native/tree/newArch


Environment

  • Xcode: 16.2
  • React Native: 0.76.9

Any guidance, samples, or suggestions would be greatly appreciated 🙏

— Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions