小编ani*_*teb的帖子

FCM主题 - 无法订阅主题:xxx with token:(null) - iOS

我从Firebase Messaging API收到此错误:

[Firebase/Messaging][I-FCM002010] Cannot subscribe to topic: /topics/testTopic with token: (null)
Run Code Online (Sandbox Code Playgroud)

但之前:

Messaging.messaging().subscribe(toTopic: "/topics/testTopic")
Run Code Online (Sandbox Code Playgroud)

我打印出这样的令牌:

print("TOKEN: \(InstanceID.instanceID().token() ?? "NO TOKEN")")
Run Code Online (Sandbox Code Playgroud)

结果是:

TOKEN:cXPhGQ_inE4:APA91bEKZF5depHmIm9gDliCFRCRcnJf5LYy5FMg6nhpWvKU3o3HEtr1WTBHUiCZXT4XzhVg2oqXzhtfrgf83brtLdqXii546644ciMPO80tri4JPueQBClKbaomEfoh54ku8E2lw
Run Code Online (Sandbox Code Playgroud)

因此令牌不为.

难道我做错了什么?有人帮忙吗?

ios firebase swift firebase-cloud-messaging

26
推荐指数
1
解决办法
7462
查看次数

是否有Swift代码的Github降价语言标识符?

我正在使用https://jbt.github.io/markdown-editor在线工具获取文档.我想知道是否有识别swift语法元素的标识符.

谢谢.

markdown github swift

8
推荐指数
1
解决办法
2326
查看次数

在Swift中将AirPlay集成到iOS应用

我想通过AirPlay广播广播流(到AppleTV)。我已经研究了很多与此主题相关的内容,但是发现文档确实很差。

这是AirPlay 2的Apple文档:https//developer.apple.com/documentation/avfoundation/airplay_2/getting_airplay_2_into_your_app

我发现AVRoutePickerView只有在iOS 11之后才可用。在iOS 11以下MPVolumeView需要使用。

我检查了iOS版本,集成了这些类,演员表正常工作,不买我想要的

一个黑色的屏幕同时播放出现在电视上,我无法控制音量的演员。

谁能告诉我如何简单明了地将AirPlay集成到iOS应用中?任何帮助,将不胜感激。

ios airplay apple-tv control-center swift

5
推荐指数
1
解决办法
2291
查看次数

iOS - 使用 AVPlayer 检测 URL 流是否正常工作

这是在我的代码中,从 url 播放的样子:

private func play() {
    let streamUrl = ...        
    let playerItem = AVPlayerItem(url: streamURL)
    radioPlayer = AVPlayer(playerItem: playerItem)
    radioPlayer.volume = 1.0
    do {
         try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: AVAudioSessionCategoryOptions.mixWithOthers)
         try AVAudioSession.sharedInstance().setActive(true)
         UIApplication.shared.beginReceivingRemoteControlEvents()
     } catch {
         print("Error deactivating audio session.")
     }
     radioPlayer.play()
     startListeningForStreamFail()
     stopStartButton.setImage(#imageLiteral(resourceName: "pause_btn"), for: .normal)
}
Run Code Online (Sandbox Code Playgroud)

就像上面解释的代码片段一样,在调用该.play()函数后,我正在调用startListeningForStreamFail(),它将当前视图控制器注册到主线程上的两种类型的通知。

private func startListeningForStreamFail() {
    DispatchQueue.main.async { [weak self] in
        NotificationCenter.default.addObserver(self as Any, selector: #selector(self?.playerItemFailedToPlay), name: NSNotification.Name.AVPlayerItemPlaybackStalled, object: self?.radioPlayer?.currentItem)
        NotificationCenter.default.addObserver(self as Any, selector: #selector(self?.playerItemFailedToPlay), name: NSNotification.Name.AVPlayerItemFailedToPlayToEndTime, object: self?.radioPlayer?.currentItem)
    } …
Run Code Online (Sandbox Code Playgroud)

notifications ios avplayer swift avplayeritem

2
推荐指数
1
解决办法
3983
查看次数