在Firebase IOS示例中找不到属性委托

时间:2018-01-29 07:53:19

标签: ios objective-c firebase

我尝试使用他们的api指南将Firebase添加到我的IOS应用程序中, 我正在添加"注册远程通知"我的didFinishLaunchingWithOptions中的AppDelegate.m下的代码由Firebase建议。 但它写了一个错误说

Property 'delegate' not found on object of type 'id' 

这是我的didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  //Register app for remote notifications
  if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
    UIUserNotificationType allNotificationTypes =
    (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
    UIUserNotificationSettings *settings =
    [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
    [application registerUserNotificationSettings:settings];
  } else {
    // iOS 10 or later
    #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
    // For iOS 10 display notification (sent via APNS)
    [UNUserNotificationCenter currentNotificationCenter].delegate = self;
    UNAuthorizationOptions authOptions =
    UNAuthorizationOptionAlert
    | UNAuthorizationOptionSound
    | UNAuthorizationOptionBadge;
    [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) {
    }];
#endif
  }

  [application registerForRemoteNotifications];

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我在iOS 11&amp ;;中执行了您的代码iOS 8,为我工作。我认为它正在崩溃其他地方。