【发布时间】:2021-09-15 07:47:55
【问题描述】:
我正在运行 iOS13.3 的越狱 iPhone 6s 上使用 Linux 上的 theos 开发一个 swift 应用程序。我有一些简单的 swift UI 代码来显示一个按钮来请求本地通知权限:
import SwiftUI
import UserNotifications
struct MainView: View {
var body: some View {
Button("Request Permission") {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert]) { success, error in
NSLog("success:\(success) error:\(error)")
}
}
}
}
这总是打印success:false error:nil,屏幕上不会弹出任何内容。如果我使用UNUserNotificationCenter.current().getNotificationSettings() 打印应用程序的当前通知设置,我会得到
<UNNotificationSettings: 0x2824a8a80;
authorizationStatus: NotDetermined
notificationCenterSetting: NotSupported
soundSetting: NotSupported
badgeSetting: NotSupported
lockScreenSetting: NotSupported
carPlaySetting: NotSupported
announcementSetting: NotSupported
criticalAlertSetting: NotSupported
alertSetting: NotSupported
alertStyle: None
groupingSetting: Default
providesAppNotificationSettings: No>
(我对上面的部分进行了格式化,所以它不是一条长线)
我的主要问题是:
- 为什么
requestAuthorization失败了? - 为什么在上面的设置中一切都设置为
NotSupported?
如果有什么不同,这里是我的 info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>cync</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon29x29</string>
<string>AppIcon40x40</string>
<string>AppIcon57x57</string>
<string>AppIcon60x60</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon29x29</string>
<string>AppIcon40x40</string>
<string>AppIcon57x57</string>
<string>AppIcon60x60</string>
<string>AppIcon50x50</string>
<string>AppIcon72x72</string>
<string>AppIcon76x76</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.enricozb.cync</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
【问题讨论】:
-
您只需询问一次并获得弹出窗口。你得到过一次弹出窗口吗?如果是这样,请删除手机上的应用,然后重试。
-
弹出窗口从未出现过
标签: ios swift linux jailbreak theos