I’ve developed MAUI app utilizing Visible Studio 2022 v 17.14.16 and .NET 9. I’ve already developed Android app and it’s on Google Play Retailer.
Now I’m creating iOS MAUI app so I’ve enabled iOS as a goal Platform. Goal .Web runtime as .Web 9 and Minimal goal iOS framework is 16.0.
I’ve carried out Push Notification performance by including Notification Service Extension (NSE) Undertaking in Visible Studio Home windows.
For each Most important app and NSE, I’ve created App Id. For Most important App, App Id I’ve enabled Push Notification and App Group capabilities and for NSE mission I’ve enabled App Group functionality in Apple developer portal. I’ve created App group (group.com.firm.id.title) and configured to App Id of each Most important App and NSE mission.
In App.xaml.cs file, I’ve initialized OneSignal like beneath:
OneSignal.Initialize("OneSignal_App_Id");
OneSignal.Notifications.RequestPermissionAsync(true);
In Most important app’s Data.plist, I’ve added beneath keys for Push notification-
Most important app Data.plist
<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</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>Belongings.xcassets/appicon.appiconset</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundleIdentifier</key>
<string>com.firm.id.title</string>
<key>CFBundleDisplayName</key>
<string>Cell app</string>
<key>CFBundleName</key>
<string>Cell app</string>
<key>MinimumOSVersion</key>
<string>16.0</string>
<key>NSCameraUsageDescription</key>
<string>We want digital camera entry to seize photographs.</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.reverseClientId</string>
</array>
</dict>
</array>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>OneSignal_app_groups_key</key>
<string>group.com.firm.id.title.onesignal</string>
Most important app’s Entitlements.plist
<?xml model="1.0" encoding="utf-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>aps-environment</key>
<string>improvement</string>
<key>com.apple.safety.application-groups</key>
<array>
<string>group.com.firm.id.title.onesignal</string>
</array>
Most important App .csproj Configuration
<PropertyGroup>
<TargetFrameworks>net9.0-android35.0;net9.0-ios18.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>allow</ImplicitUsings>
</PropertyGroup>
<SupportedOSPlatformVersion Situation="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">16.0</SupportedOSPlatformVersion>
<PropertyGroup Situation="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net9.0-ios18.0|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<MtouchLink>None</MtouchLink>
<CodesignEntitlements>PlatformsiOSEntitlements.plist</CodesignEntitlements>
</PropertyGroup>
<ItemGroup Situation="'$(TargetFramework)' == 'net9.0-ios18.0'">
<PackageReference Embrace="OneSignalSDK.DotNet" Model="5.2.2" />
</ItemGroup>
<ItemGroup Situation="'$(TargetFramework)' == 'net9.0-ios18.0'">
<ProjectReference Embrace="..OneSignalNotificationServiceExtensionOneSignalNotificationServiceExtension.csproj">
<IsAppExtension>true</IsAppExtension>
</ProjectReference>
</ItemGroup>
NSE Data.plist
<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>OneSignalNotificationServiceExtension</string>
<key>CFBundleName</key>
<string>OneSignalNotificationServiceExtension</string>
<key>CFBundleIdentifier</key>
<string>com.firm.id.title.OneSignalNotificationServiceExtension</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.usernotifications.service</string>
<key>NSExtensionPrincipalClass</key>
<string>NotificationService</string>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>MinimumOSVersion</key>
<string>16.0</string>
<key>OneSignal_app_groups_key</key>
<string>group.com.firm.id.title.onesignal</string>
</dict>
</plist>
NSE Entitlements.plist
<?xml model="1.0" encoding="utf-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="1.0">
<dict>
<key>com.apple.safety.application-groups</key>
<array>
<string>group.com.firm.id.title.onesignal</string>
</array>
</dict>
</plist>
NSE configuration
<Undertaking Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0-ios18.0</TargetFramework>
<OutputType>Library</OutputType>
<Nullable>allow</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<SupportedOSPlatformVersion>16.0</SupportedOSPlatformVersion>
<IsAppExtension>True</IsAppExtension>
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<ApplicationId>com.firm.id.title.OneSignalNotificationServiceExtension</ApplicationId>
</PropertyGroup>
<PropertyGroup Situation="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Situation="'$(Configuration)|$(Platform)'=='Launch|AnyCPU'">
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<ItemGroup>
<PackageReference Embrace="OneSignalSDK.DotNet" Model="5.2.2" />
</ItemGroup>
</Undertaking>
NotificationServiceClass
utilizing System;
utilizing Basis;
utilizing OneSignalSDK.DotNet;
utilizing OneSignalSDK.DotNet.iOS;
utilizing UIKit;
utilizing UserNotifications;
namespace OneSignalNotificationServiceExtension
{
[Register("NotificationService")]
public class NotificationService : UNNotificationServiceExtension
{
Motion<UNNotificationContent> ContentHandler { get; set; }
UNMutableNotificationContent BestAttemptContent { get; set; }
UNNotificationRequest ReceivedRequest { get; set; }
protected NotificationService(IntPtr deal with) : base(deal with)
{
// Word: this .ctor shouldn't comprise any initialization logic,
// it solely exists in order that the OS can instantiate an occasion of this class.
}
public override void DidReceiveNotificationRequest(UNNotificationRequest request, Motion<UNNotificationContent> contentHandler)
{
Console.WriteLine("DidReceive**********************");
ReceivedRequest = request;
ContentHandler = contentHandler;
BestAttemptContent = (UNMutableNotificationContent)request.Content material.MutableCopy();
NotificationServiceExtension.DidReceiveNotificationExtensionRequest(request, BestAttemptContent, contentHandler);
}
public override void TimeWillExpire()
{
NotificationServiceExtension.ServiceExtensionTimeWillExpireRequest(ReceivedRequest, BestAttemptContent);
ContentHandler(BestAttemptContent);
}
}
}
Under is my payload of notification I’m passing by way of API:
var notification = new Notification(appId: _AppId)
{
Contents = new StringMap(en: message),
IncludeExternalUserIds = externalUserId,
IosBadgeType = "Enhance",
IosBadgeCount = 1,
MutableContent = true
};
In each Most important app and NSE mission properties iOS Bundle signing, I’ve chosen Handbook Provisioning and chosen Signing Id and Provisioning Profile resp. for Most important App and NSE
I’ve paired Visible Studio Home windows with Mac. I get Push notifications on my app. On Notification Heart it’s exhibiting appropriate rely however challenge is on app icon badge rely isn’t rising, it’s caught at 1 solely.
I believe NSE isn’t working as a result of if I add any prefix to physique in DidReceiveNotification methodology, then it isn’t exhibiting.
I get beneath error:
INFO: An error occurred whereas forwarding HotReload native tunnel: System.IO.IOException: USB join timeout (ENODATA), doubtless as a result of the app did not launch. Please overview system logs and/or crash studies for extra info.
at Xamarin.MacDev.AggregateAsyncResult.CheckError(Boolean cancelled)
at Xamarin.MacDev.IPhoneDevice.EndConnectStream(IAsyncResult outcome)
at System.Threading.Duties.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Motion`1 endAction, Process`1 promise, Boolean requiresSynchronization)
--- Finish of stack hint from earlier location ---
at Xamarin.Messaging.IDB.IPhoneUsbLocalTunnelConnection.StartLocalTunnelAsync()
at Xamarin.Messaging.IDB.LaunchAppMessageHandler.ForwardLocalTunnelsAsync(LaunchAppMessage, IPhoneDevice)
ERROR: [iOS HotReload] Failed to connect with "iPhone" over USB on port 11000.
For this error- I’ve disabled / unchecked .NET Scorching Reload and uncheck Allow Scorching Reload however similar error persists.
Is there something I’m lacking due to which badge rely isn’t rising? If there isn’t a communication occurs between Most important app and NSE then what must be achieved?


