OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

[question]: What is the replacement API for IdsAvailable to retrieve the PlayerId in OneSignalSDK.Xamarin? #347

Closed matthewrdev closed 1 year ago

matthewrdev commented 1 year ago

How can we help?

In order to comply with Googles minimum Android v31 targeting requirements, I am migrating a clients app's OneSignal SDK from the Com.OneSignal nuget package to the OneSignalSDK.Xamarin package.

In the previous SDK, there is the following method/callback:

OneSignal.Current.IdsAvailable(IdsAvailable);

private void IdsAvailable(string userID, string pushToken) {
     print("UserID:"  + userID);
     print("pushToken:" + pushToken);
}

However, in the new SDK, the OneSignal.Default instance does not have a matching method nor a GetPlayerId function (that I can see).

The SDK documentation still shows IdsAvailable as a usable method (referring to the old OneSignal.Current methodology) but does not show a replacement.

Code of Conduct

jkasten2 commented 1 year ago

@matthewrdev Thanks for your question. Depending on your use-cases you may want to use OneSignal.Default.PushSubscriptionState.userId and / or PushSubscriptionStateChanged

matthewrdev commented 1 year ago

@jkasten2 Excellent, thanks for the quick answer!

This resolved the issue and I've successfully completed the migration.