我目前正在处理通知,但我没有成功从 Firebase FCM 收到任何通知。
podfile 配置是:
target 'Project' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Project
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
Run Code Online (Sandbox Code Playgroud)
我已经激活Push Notifications
并Remote Notifications
从Background fetches
并且已经阅读了stackoverflow
当前类似的另一个主题,在这里
我想和你分享我的 AppDelegate 代码,但首先我不得不说谷歌的推送通知文档似乎有点混乱,因为这里有很多覆盖的方法,每个教程都有不同的方式来完成接收通知。
我已经进口了这些
import Firebase
import FirebaseInstanceID
import UserNotifications
import FirebaseMessaging
Run Code Online (Sandbox Code Playgroud)
然后是代表团
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate{
...
}
Run Code Online (Sandbox Code Playgroud)
然后这里是 willFinishLaunchWithOptions 方法
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey …
Run Code Online (Sandbox Code Playgroud) apple-push-notifications firebase swift firebase-cloud-messaging
我正在尝试创建一个CocoaPod
,当我尝试时出现有关source_files 的pod lib lint
错误ERROR | [iOS] file patterns: The
pattern did not match any file.
我试图以BlinkingLabel
pod 为例并用于Gitlab
存储我的.git
. 我成功地标记了它1.0.0
并且它起作用了。
我使用了我的CocoaPod
inExample for Pod
及其工作但出现了错误:
Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5
-> BlinkingLabel (1.0.0)
- ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.
- NOTE | xcodebuild: note: Using new build system
- NOTE …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 PencilKit,但无法在应用程序中绘制任何内容。我设置我的代码如下。
import UIKit
import PencilKit
class DrawingViewController: UIViewController {
var canvasView: PKCanvasView!
override func viewDidLoad() {
super.viewDidLoad()
let canvasView = PKCanvasView(frame: view.bounds)
canvasView.allowsFingerDrawing = false
view.addSubview(canvasView)
canvasView.translatesAutoresizingMaskIntoConstraints = false
canvasView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
canvasView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
canvasView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
canvasView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
canvasView.backgroundColor = UIColor.lightGray
canvasView.tool = PKInkingTool(.pen, color: .black, width: 10)
}
}
Run Code Online (Sandbox Code Playgroud)
我期望在 canvasView 中绘制/墨迹,但当我尝试该应用程序时没有响应。我的设备运行的是 13.2,所以目标没有问题。我还从 WWDC 2019会议下载了 Apple 的应用程序,但它无法在模拟器中运行。为了澄清起见,我还在真实设备中测试了它,但在任何使用PencilKit的应用程序中都没有响应。
我正在构建一个用于生产的 Cocoa 应用程序,当我创建一个NSViewController
用于路由而不NSStoryboard
实例化的应用程序时,我收到如下错误。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: ContentFully.AnotherController in bundle (null).
Run Code Online (Sandbox Code Playgroud)
实际上,我通过使用NSViewController
添加解决了我的问题NSStoryboard
,但我想了解当我以编程方式调用它时发生了什么以及为什么崩溃?
工作场景
let storyboard = NSStoryboard(name: "Dashboard", bundle: nil)
let vc = storyboard.instantiateInitialController() as! AnotherController
Run Code Online (Sandbox Code Playgroud)
崩溃场景
let vc = AnotherController()
self.view.window?.contentViewController = vc
Run Code Online (Sandbox Code Playgroud)
即使我完全以编程方式创建一个类并且与NSStoryboard
它无关,当我更改contentViewController
. NSBundle
是否需要搜索每个控制器Swift
?
提前致谢