小编use*_*013的帖子

Firebase - 无法指定"AppDelegate"类型的值来键入"UNUserNotificationCenterDelegate?"

我总是在使用本教程部署firebase时编译错误:https://firebase.google.com/docs/cloud-messaging/ios/client 我的部署SDK是9.0.

我得到的错误:

我怎样才能解决这个问题?

无法指定"AppDelegate"类型的值来键入"UNUserNotificationCenterDelegate?"

第一个场景 - 我一步一步地做了什么(按照教程):

  • pod init包含以下内容:pod'Firebase/Core'pod'Firebase/Messaging'
  • pod安装
  • 在AppDelegate类之上"导入Firebase"

第二种情况 - 通过github存储库下载谷歌演示iOS客户端应用程序(https://github.com/firebase/quickstart-ios下的"messaging"文件夹)

  • 编译他们的应用...工作正常.
  • 按照以下步骤将我们现有的XCode项目的逻辑编译为:
  • pod init包含以下内容:pod'Firebase/Messaging'
  • pod安装
  • 导入以下内容:UIKit,UserNotifications,Firebase,FirebaseInstanceID,FirebaseMessaging

AppDelegate中的代码:

func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // [START register_for_notifications]
        if #available(iOS 10.0, *) {
            let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(
                options: authOptions,
                completionHandler: {_,_ in })
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.current().delegate = self
            // For iOS 10 data message (sent via …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift firebase-cloud-messaging

11
推荐指数
1
解决办法
7706
查看次数

无法将调试器附加到UNNotificationServiceExtension

我无法在UNNotificationServiceExtension中使用调试器.

这是我在尝试将调试器附加到UNNotificationServiceExtension时所做的事情:

  1. 运行应用程序
  2. 在"Testing"UNNotificationServiceExtension中设置断点
  3. 选择Debug> Attach to Process by PID或Name>选择"Testing"UNNotificationServiceExtension
  4. XCode表示"测试正在等待附加"

  1. 然后我发送推送通知,我的iPhone显示通知,但调试器没有达到断点.相反,XCode显示"Thread1:signal SIGKILL".

Thread1:信号SIGKILL

有谁知道如何使调试器在UNNotificationServiceExtension中工作?

xcode ios swift

10
推荐指数
1
解决办法
835
查看次数

删除标签栏项目之间的间距(左右)

在“项目位置”选项上使用“填充”值时,如何删除标签栏项目之间的间距?

我尝试了以下方法:

    let tabBarController = window!.rootViewController as! UITabBarController
    tabBarController.tabBar.itemSpacing = 0
    let numberOfItems = CGFloat(tabBarController.tabBar.items!.count)
    let tabBarItemSize = CGSize(width: tabBarController.tabBar.frame.width / numberOfItems, height: tabBarController.tabBar.frame.height)
    tabBarController.tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.secondaryHighlight(), size: tabBarItemSize).resizableImage(withCapInsets: UIEdgeInsets.zero)
    for item in tabBarController.tabBar.items! {
        item.imageInsets = UIEdgeInsetsMake(0, 0, 0, 0)
    }

extension UIImage {

    class func imageWithColor(color: UIColor, size: CGSize) -> UIImage {
        let rect: CGRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContextWithOptions(size, false, 0)
        color.setFill()
        UIRectFill(rect)
        let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        return image …
Run Code Online (Sandbox Code Playgroud)

uitabbaritem ios swift

6
推荐指数
1
解决办法
2789
查看次数