You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AppDelegate.m报Expected identifier or '('错误及Firebase推送不显示求助

问题修复方案

一、语法错误(Expected identifier or '(')修复

错误原因

你在didFinishLaunchingWithOptions方法中添加FIRApp初始化代码后,提前关闭了方法的大括号,导致后续代码变成了独立的无主代码块,同时重复调用了两次[FIRApp configure],触发语法报错。

修正代码

你只需要把原来的didFinishLaunchingWithOptions相关代码替换成下面的内容即可,其他代码完全不用改:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // 只保留一次FIRApp初始化,放在方法最开头
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
#if DEBUG
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"shopinnadmin"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;
  
  // 删掉重复的[FIRApp configure]; 避免重复初始化
  return YES;
}

二、推送通知无法弹出排查点

  • 确认Xcode项目的Signing & Capabilities中已经添加了Push Notifications和Background Modes能力,Background Modes勾选了Remote notifications
  • 确认前端代码已经调用了PushNotificationIOS.requestPermissions()方法申请通知权限,且用户已经同意授权
  • 确认Firebase控制台已经上传了正确的APNs认证密钥/证书,且Bundle ID和项目配置一致
  • 测试推送时优先用真机测试,模拟器无法接收APNs远程推送

内容的提问来源于stack exchange,提问作者Official Berry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 05:06:04