Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

Xamarin.Firebase.IOS.CloudMessaging receive FCM token but notifications not working #418

Open
@davidtabor90

Description

@davidtabor90

Hi,

I'm new in Firebase Cloud Messaging and I trying to use it with our Xamarin.iOS app.

I generate application in Firebase and set all certificates, ids, etc.
Than I add nuget to project, GoogleService-Info.plist, enable Background mode - Remote notification in Entitlements.plist, enable Push notification in Info.plist.

I'm calling method at AppDelegate.FinishedLaunching for init remote notification. Than I get fcm token but if I try send cloud message (Grow - Cloud Messaging) to this token nothing happend on phone. Even if app is running or not.

I don't know what next.

Uninstall and install I tried too.

Next wierd thing that Firebase still notice:

Run your app to verify installation
Checking if the app has communicated with our servers. You may need to uninstall and reinstall your app.

Thanks for your advices.

private void SetFirebaseCloudMessaging()
{
	Firebase.Core.App.Configure();
	Messaging.SharedInstance.Delegate = this;

	// Register your app for remote notifications.
	if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
	{
		// For iOS 10 display notification (sent via APNS)
		UNUserNotificationCenter.Current.Delegate = this;

		var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
		UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
			Console.WriteLine(granted);
		});
	}
	else
	{
		// iOS 9 or before
		var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
		var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
		UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
	}

	UIApplication.SharedApplication.RegisterForRemoteNotifications();
}

[Export("messaging:didReceiveRegistrationToken:")]
public void DidReceiveRegistrationToken(Messaging messaging, string fcmToken)
{
	Console.WriteLine($"DEBUG: Firebase registration token: {fcmToken}");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions