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

Token generated on iOS is similar to Android token. Cannot received push notification. #337

Open
gautambjain opened this issue Aug 31, 2024 · 5 comments

Comments

@gautambjain
Copy link

On iOS, the token generated is of below format:

csxgLoBcFkCLgJ7xTe1YML:APA91bFJi7WXJh_-0nRXTlDvy_RRh1KY_vD3s58ScMKzcD-VIGcZ4tNX6sq9KSOJPB2YWsecPzHRchUufqeBa9mSMPYBXxeIYEHjEr9frHG8ip_QiAPmxP9dwwFyo9HO3_mSS9H4IhD5

Due to this, I don't receive push notification on NotificationReceived.

So I disabled TokenChanged and wrote my own handler like below in AppDelegate:

[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
public void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)

[Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
public void  DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)

In order to register for remote notifications, I called:

UIApplication.SharedApplication.RegisterForRemoteNotifications();

After making the above changes, token generated in below format

512AE6E911F52E3D1EB76D8790AA3B327C9106A65F54D1DE6A18A6751E0BA7FB

And I started receiving push notifications.

I am sharing my experience here so that you can point out what am I missing. These look like bugs. And if you think I am using Plugin.Firebase the wrong way, then kindly show the way please.

@AdamEssenmacher
Copy link
Collaborator

@gautambjain
Copy link
Author

I am using Plugin.Firebase, which I believe have implemented as per the link you shared. My belief is that Plugin.Firebase covers the internals of your iOS components. That's what I see from the source code (Plugin.Firebase).

I am receiving token but of different format (very similar to Android token) on iOS. Why would that be?

@AdamEssenmacher
Copy link
Collaborator

Plugin.Firebase is just a cross-platform wrapper over the .NET binding libraries for each platform, which themselves are just wrappers around the native Firebase libraries.

Plugin.Firebase does not configure your platform projects for you.

@suariana
Copy link

suariana commented Dec 6, 2024

UIApplication.SharedApplication.RegisterForRemoteNotifications();

@gautambjain may i know detailed about code changed that you've write to receive token like you've got?
thank you

@gautambjain
Copy link
Author

@suariana - It is hard to recollect the exact changes I made to fix this.

But I know that I reverted back the old methods of receiving push notifications. I had just installed Plugin.Firebase so that the require pre-requisites are installed. As Adam said above, we have do manually do the configuration in the code to receive the push notifications in the lines of:

[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
[Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]

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

3 participants