-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicKitModule.swift
More file actions
35 lines (31 loc) · 871 Bytes
/
MusicKitModule.swift
File metadata and controls
35 lines (31 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// MusicKitModule.swift
// macOSNativeModuleExample-macOS
//
// Created by Anthony on 12/22/23.
//
import Foundation
import MusicKit
@objc(MusicKitModule) class MusicKitModule: NSObject {
@objc static func requiresMainQueueSetup() -> Bool { return true }
/// Synchronous (main thread)
@objc func currentAuthorizationStatus() -> String {
if #available(macOS 12.0, *) {
let status = MusicAuthorization.currentStatus.rawValue
return status
} else {
return "Unsupported iOS"
}
}
/// Asynchronous
@objc func requestAuthorization(_ resolve: @escaping(RCTPromiseResolveBlock), rejecter reject: RCTPromiseRejectBlock) {
if #available(macOS 12.0, *) {
Task {
let status = (await MusicAuthorization.request()).rawValue
resolve(status)
}
} else {
resolve("Unsupported iOS")
}
}
}