first commit

This commit is contained in:
2025-07-14 00:42:12 +08:00
commit 1632c3329d
45 changed files with 2714 additions and 0 deletions

View File

@ -0,0 +1,9 @@
using Foundation;
namespace HeartRateMonitorAndroid;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

32
Platforms/iOS/Info.plist Normal file
View File

@ -0,0 +1,32 @@
<?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>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</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>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>

View File

@ -0,0 +1,63 @@
using Foundation;
using UserNotifications;
namespace HeartRateMonitorAndroid.Platforms.iOS
{
// iOS平台特定的通知帮助类
public static class IosNotificationHelper
{
// 请求通知权限
public static async Task RequestNotificationPermission()
{
var options = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound;
var center = UNUserNotificationCenter.Current;
var result = await center.RequestAuthorizationAsync(options);
// 权限请求结果处理
if (result.Item1)
{
// 已获得权限
Console.WriteLine("通知权限获取成功");
}
else
{
// 权限被拒绝
Console.WriteLine("通知权限被拒绝");
}
}
// 显示本地通知
public static void ShowNotification(string title, string body, double timeIntervalSeconds = 0.1)
{
var content = new UNMutableNotificationContent
{
Title = title,
Body = body,
Sound = UNNotificationSound.Default
};
// 设置触发器
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(timeIntervalSeconds, false);
// 创建请求
var requestId = Guid.NewGuid().ToString();
var request = UNNotificationRequest.FromIdentifier(requestId, content, trigger);
// 添加请求
UNUserNotificationCenter.Current.AddNotificationRequest(request, (error) =>
{
if (error != null)
{
Console.WriteLine($"通知发送失败: {error}");
}
});
}
// 取消所有通知
public static void CancelAllNotifications()
{
UNUserNotificationCenter.Current.RemoveAllPendingNotificationRequests();
UNUserNotificationCenter.Current.RemoveAllDeliveredNotifications();
}
}
}

15
Platforms/iOS/Program.cs Normal file
View File

@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;
namespace HeartRateMonitorAndroid;
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the minimum required version of the Apple Privacy Manifest for .NET MAUI apps.
The contents below are needed because of APIs that are used in the .NET framework and .NET MAUI SDK.
You are responsible for adding extra entries as needed for your application.
More information: https://aka.ms/maui-privacy-manifest
-->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>E174.1</string>
</array>
</dict>
<!--
The entry below is only needed when you're using the Preferences API in your app.
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict> -->
</array>
</dict>
</plist>