Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APNS device token not set before retrieving FCM Token for Sender ID '...'. #202

Open
wbhotia-bbl opened this issue Oct 5, 2023 · 3 comments

Comments

@wbhotia-bbl
Copy link

wbhotia-bbl commented Oct 5, 2023

Hi,

iOS push notifications stopped working and I have not been able to resolve it.

FCM Error: APNS device token not set before retrieving FCM Token for Sender ID '...'. Notifications to this FCM Token will not be delivered over APNS. Be sure to re-retrieve the FCM token once the APNS device token is set.

AWS SNS Error: iOS device token must not be more than 400 hexadecimal characters.

I believe the issue is due the FCM Error mentioned above. I have enabled Background Modes but still fails.

info-plist-cap-bm

Found that, AWS SNS does not support FCM v1.0 yet so I disabled FCM v1.0 and still get the same errors.

Has anyone had this issue before and if so please help.

My setup:

MauiProgram.cs

    private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder)
    {
        builder.ConfigureLifecycleEvents(events =>
        {
#if IOS
            events.AddiOS(iOS => iOS.WillFinishLaunching((_, _) =>
            {
                CrossFirebase.Initialize(CreateCrossFirebaseSettings());
                return false;
            }));
#else
            events.AddAndroid(android => android.OnCreate((activity, _) =>
                CrossFirebase.Initialize(activity, CreateCrossFirebaseSettings())));
#endif
        });

        builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current);
        return builder;
    }

AppDelegate.cs

public override bool WillFinishLaunching(UIApplication app, NSDictionary options)
{
    var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
    UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
    {
        if (granted && error == null)
        {
            this.InvokeOnMainThread(() =>
            {
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            });
        }
    });

    return base.WillFinishLaunching(app, options);
}

VS Community 2022 v17.7.4
Plugin.Firebase v2.0.5
.NET 6
iOS Target SDK 16.4

@TobiasBuchholz
Copy link
Owner

Hey and sorry for the late response. Could you please provide a sample project that demonstrates this issue?

@khalil2099
Copy link

my code to initialise FCM is the same as above, i can receive push notification on iOS 15, but not receiving any push notification on iOS 17.

on FCM setting, im using APN Auth Key. I have not tried APN Certificate.

anyone having problem like me ?

@LennoxP90
Copy link

LennoxP90 commented Jun 7, 2024

I am having the same issue, my client is not generating an fcm token to be used by my server app. My setup is pretty unique I elect to pass the .plist .json information through a socket call from my server so i do not have to hardcode anything in the app (My app is a self contained chat app that different customers use).

The main purpose of this is so that our customers can use their own google firebase account

Keep in mind all of this worked fine in Xamarin with the legacy libraries. Same firebase account and config files.

CrossFirebase.Initialize( null,
                          new Firebase.Core.Options( saved_request.AppId,
                                                     saved_request.ProjectNumber )
                          {
                            ProjectId = saved_request.ProjectId,
                            ApiKey = saved_request.ApiKey,
                            BundleId = "<hard-coded-value>",
                            StorageBucket = saved_request.StorageBucket
                          } );
FirebaseCloudMessagingImplementation.Initialize();

var token = await Firebase.CloudMessaging.Messaging.SharedInstance.RetrieveFcmTokenAsync( saved_request.ProjectNumber );

the retrieve token fails with Error Domain=com.google.fcm Code=505 "No APNS token specified before fetching FCM Token"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants