【发布时间】:2016-10-17 20:16:42
【问题描述】:
在使用 FCM tutorial for ios 实现 FCM 消息传递之后,这里是我在 appdelegate.m 中使用的代码
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
UIUserNotificationType allNotificationTypes =
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings =
[UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
// iOS 10 or later
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
UNAuthorizationOptions authOptions =
UNAuthorizationOptionAlert
| UNAuthorizationOptionSound
| UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
}
];
// For iOS 10 display notification (sent via APNS)
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
// For iOS 10 data message (sent via FCM)
[[FIRMessaging messaging] setRemoteMessageDelegate:self]; // here the method is not defined //
#endif
}
这里是 appdelegate.h
//
// AppDelegate.h
// lechef
//
// Created by Zakaria Darwish on 9/5/16.
// Copyright © 2016 CodeBee. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "constant.h"
#include <AudioToolbox/AudioToolbox.h>
#import "MPGNotification.h"
#include <AudioToolbox/AudioToolbox.h>
#include "constant.h"
@import UserNotifications;
@import GoogleMaps;
@import GooglePlaces;
@import Firebase;
@import FirebaseInstanceID;
@import FirebaseMessaging;
@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
我尝试搜索 firemessaging 委托,堆栈上的一些人说不断更新库,它将被修复 here 我无法弄清楚我做错了什么..
【问题讨论】:
-
你设法让它工作了吗? Firebase 工程师,请更新您的文档。我必须弄清楚很多事情——从让 import 语句正常工作,到 AppDelegate 中的每一行。
标签: ios objective-c firebase google-cloud-messaging firebase-cloud-messaging