my function is
var _notifications = await OnStarts();
if (_notifications == true)
{
var _isValid = await Process_Login(_base_url, _access_token, Group_Type);
}
async Task OnStarts()
{
// Handle when your app starts
CrossFirebasePushNotification.Current.Subscribe("general");
CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) =>
{
System.Diagnostics.Debug.WriteLine($"TOKEN REC: {p.Token}");
};
System.Diagnostics.Debug.WriteLine($"TOKEN: {CrossFirebasePushNotification.Current.Token}");
var isvalid = await PushNotification(CrossFirebasePushNotification.Current.Token);
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
try
{
System.Diagnostics.Debug.WriteLine("Received");
if (p.Data.ContainsKey("body"))
{
Device.BeginInvokeOnMainThread(() =>
{
mPage.Message = $"{p.Data["body"]}";
mPageM.Message = $"{p.Data["body"]}";
});
}
}
catch (Exception ex)
{
mPage.Message = ex.ToString();
mPageM.Message = ex.ToString();
}
};
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
//System.Diagnostics.Debug.WriteLine(p.Identifier);
System.Diagnostics.Debug.WriteLine("Opened");
foreach (var data in p.Data)
{
System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
}
if (!string.IsNullOrEmpty(p.Identifier))
{
Device.BeginInvokeOnMainThread(() =>
{
mPage.Message = p.Identifier;
mPageM.Message = p.Identifier;
});
}
else if (p.Data.ContainsKey("color"))
{
Device.BeginInvokeOnMainThread(() =>
{
mPage.Navigation.PushAsync(new ContentPage()
{
BackgroundColor = Color.FromHex($"{p.Data["color"]}")
});
});
}
else if (p.Data.ContainsKey("aps.alert.title"))
{
Device.BeginInvokeOnMainThread(() =>
{
mPage.Message = $"{p.Data["aps.alert.title"]}";
mPageM.Message = $"{p.Data["aps.alert.title"]}";
});
}
};
CrossFirebasePushNotification.Current.OnNotificationAction += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Action");
if (!string.IsNullOrEmpty(p.Identifier))
{
System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}");
foreach (var data in p.Data)
{
System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
}
}
};
CrossFirebasePushNotification.Current.OnNotificationDeleted += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Dismissed");
};
return true;
}
private async Task<bool> PushNotification(string fcm_id)
{
var Access_Token = Application.Current.Properties["Access_token"];
var base_url = Application.Current.Properties["_BASEURL"];
var _url = base_url + "registerFCM";
var fcm_type = "ios";
var fcm_server_key = "----8AU7Fs956WkhtdQ4_oTNGx6f7v-7K_1UgQvCzFA98OsBsh9IJC93g-YochmBT5TkCzh42sG8-fKUre9HtztI7a7q3c1tI2ELJV4";
//new key
var data = "AccessToken=" + Access_Token.ToString() + "&fcm_id=" + fcm_id + "&fcm_type=" + fcm_type.ToString()
+ "&fcm_server_key=" + fcm_server_key.ToString() + "";
HttpResponseMessage response = await RestClient.GetRestApi(_url, data);
if (response.IsSuccessStatusCode == true)
{
var resContent = response.Content;
var readAsStringAsync = await resContent.ReadAsStringAsync();
var responseString = readAsStringAsync.Trim();
if (responseString != null)
{
var res = responseString.ToString();
}
}
return true;
}
my problem is I have not received the auto message in my apps.all steps are covered by with us like appDalegate,and info.plist, active the background mode enable with remote notification.so who can get the message on my devices with web api to provide the notification?