Мой вопрос касается получения токена FCM с помощью FirebaseApp.InitializeApp подхода и НЕ / игнорирования с помощью google-services.json для переключения между различными проектами в режиме SingleAPK в Xamarin Android C # .Пожалуйста, дайте мне знать, как мы можем получить токен FCM из AddOnCompleteListener или AddOnSuccessListener методов ??
Using following Packages,
1.) Xamarin.Firebase.Iid.70.1620.0-preview2
Which Contains,
public interface IInstanceIdResult : IJavaObject, IDisposable
{
string Id { get; }
string Token { get; }
}
2.) Xamarin.GooglePlayServices.Tasks.70.1501.0-preview2
which Contains,
A.) public virtual Task AddOnCompleteListener(IOnCompleteListener p0);
--> public interface IOnCompleteListener : IJavaObject, IDisposable
--> void OnComplete(Task p0);
B.) public abstract Task AddOnSuccessListener(IOnSuccessListener p0);
--> public interface IOnSuccessListener : IJavaObject, IDisposable
--> void OnSuccess(Java.Lang.Object result);
As OnSuccess(Java.Lang.Object result) has Java.Lang.Object which should have been OnSuccess(IInstanceIdResult result) but not.
Code:
After Initializing FirebaseApp.InitializeApp in OnCreate of MainActivity.cs
FirebaseMessaging.Instance.AutoInitEnabled = true;
await FirebaseInstanceId.Instance.GetInstanceId().AddOnSuccessListener(new ClassIOnCompleteListener<IInstanceIdResult>());
internal class ClassIOnCompleteListener<IInstanceIdResult> : Java.Lang.Object, IOnCompleteListener
{
public void OnComplete(Android.Gms.Tasks.Task task)
{
try
{
if (!task.IsSuccessful)
{
}
else
{
Java.Lang.Object objResult = task.Result;
// Tried Below but gives Casting Exception
//Firebase.Iid.IInstanceIdResult objResult = (Firebase.Iid.IInstanceIdResult)task.Result;
}
}
catch (Exception ex)
{ }
}
}