Skip to content

Please Help, Why Notification not working on iOS #537

@PugSingha

Description

@PugSingha

I wrote the code following the ".NET MAUI Local Notifications Guide" tutorial. It works fine on Android devices, but on iOS devices, there are no notifications no errors, and I don't know why.

Video Test
https://github.com/user-attachments/assets/d9e5574c-8165-4471-967f-552d66e2f897

Sample Project
TestNoti.zip

Code

MauiProgram.cs

public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .UseMauiCommunityToolkit()
                .UseLocalNotification()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("DB_HELVETHAICA_X_MED.ttf", "FontTitle");
                    fonts.AddFont("DB_HELVETHAICA_X_LI.ttf", "FontHead");
                    fonts.AddFont("DB_HELVETHAICA_X_THIN.ttf", "FontBase");
                });
#if DEBUG
            builder.Logging.AddDebug();
#endif

            return builder.Build();
        }
    }

App.xaml.cs File

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        LocalNotificationCenter.Current.NotificationActionTapped += OnLocalNotificationTapped;

        MainPage = new NavigationPage(new StartPage());
    }

    private void OnLocalNotificationTapped(NotificationEventArgs e)
    {
        var data = e.Request.ReturningData;

        MainThread.BeginInvokeOnMainThread(async () =>
        {
            if (data == "tab_history")
            {
                await Shell.Current.GoToAsync("//tab_history");
            }
        });
    }
}

TLocalNotifications.xaml.cs

public static async void RequestNotificationPermission()
{
    // Check if notifications are enabled
    if (await LocalNotificationCenter.Current.AreNotificationsEnabled() == false)
    {
        // Basic permission request
        await LocalNotificationCenter.Current.RequestNotificationPermission();
    }
}

private void Button_Clicked(object sender, EventArgs e)
{
    ShowNotification();
}

public async void ShowNotification()
{
    var notification = new NotificationRequest
    {
        Title = "Notifications",
        Description = "Notification Test",
        NotificationId = 1337
    };

    await LocalNotificationCenter.Current.Show(notification);
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.softcom.thailandgolfbooking" android:versionCode="48" android:versionName="1.4.6">
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.VIBRATE" />
	<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
	<uses-permission android:name="android.permission.WAKE_LOCK" />
	<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

	<!-- Optional: For exact timing -->
	<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
	<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" android:maxSdkVersion="32" />
	<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="Club"></application>
	<queries>
		<intent>
			<action android:name="android.intent.action.VIEW" />
			<data android:scheme="http" />
		</intent>
		<intent>
			<action android:name="android.intent.action.VIEW" />
			<data android:scheme="https" />
		</intent>
		<package android:name="jp.naver.line.android" />
	</queries>
</manifest>

Info.plist File

<?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>
	</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>
	<key>CFBundleDisplayName</key>
	<string>Club</string>
	<key>CFBundleIdentifier</key>
	<string>com.club.golfbookingclub</string>
	<key>UIUserInterfaceStyle</key>
	<string>Light</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>line</string>
	</array>
	<key>CFBundleLocalizations</key>
	<array>
		<string>en</string>
	</array>
	<key>CFBundleShortVersionString</key>
	<string>1.4.6</string>
	<key>CFBundleVersion</key>
	<string>1</string>

	<key>UIBackgroundModes</key>
	<array>
		<string>fetch</string>
		<string>remote-notification</string>
	</array>
</dict>
</plist>

Platform

Plugin.LocalNotification

  • Version 12.0.2

Windows

  • Tool: Visual Studio Version 17.14.20
  • Build: Android
  • .Net: 9.0.307

Macos

  • Tool: Visual Code Version 1.105.1
  • Build: iOS
  • Xcode: Version 16.4
  • .Net: 9.0.301

Smartphone Run

Android

  • Device: Samsung A04s
  • OS: Android
  • Version: 14

iOS

  • Device: iPhone 13 Pro
  • OS: iOS
  • Version 26.1

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions