Open pmikoda opened 1 year ago
@pmikoda Good questions the aliases function similarly to external user id, expect they are a key value pair where you supply both the key and value instead of just the value. This allows you to have multiple external ids if you for example you integrated with facebook and google, and wanted to represent those different ids separately.
To get the same behavior as external_user_id use the "external_id" alias label. To add an alias you can use IdentifyUserByAlias.
@emawby The type of parameter that PlayerNotificationTargetIncludeAliases
accepts is incorrect. It requires a List<string>
, while it should really require Dictionary<string, List<string>
, where the key for that dictionary should be the alias label (i.e. external_id
), the value being a list of actual IDs.
Currently it generates the following JSON payload:
{
"include_aliases": {
"alias_label": ["values"]
}
}
The alias_label
property here cannot be renamed. This is actually the case for the SDK in other languages as well.
At the moment the IncludeAliases
property is unusable due that problem.
I just bumped into this too :(
@yasikovsky Thank you for pointing this out we will address!
@emawby This is a severe issue. I suppose we should just continue using "IncludeExternalUserIds" until it's fixed, correct?
Any updates on this?
This is a bug we are fixing. In the meantime, it is safe to continue using IncludeExternalUserIds
@temcewen
Has this since been resolved ?
This fix has not yet been released. We are working on an overhaul of this library's API and Interfaces.
In the meantime, you can use IncludePlayerIds
to target by subscription ID or player ID, and use IncludeExternalUserIds
to target by external ID.
Thank you for your continued patience.
Any news about this issue?
I find that IncludeExternalUserIds works for me, and I plan on using it in production. Soon. Is that a bad idea?
@nan-li Any news from OneSignal on this? I'm constantly having problems creating a notification. It looks like the response = await appInstance.CreateNotificationAsync(notification);
fails and I don't know why.
@nan-li: i'm away from the office. When I get back I'll post working code. I'm suspect your create notification works but doesn't know anyone to send it to.
I'm working on requesting push notification permissions for Android 13 and iOS in Maui.
@nan-li This code works for me to send via user id or by tag. In my App.xml.cs: OneSignal.Initialize(Common.Constants.OneSignalID);
In my loading page I use M plus the identity column value of the user to create the userID OneSignal.Login(Common.Constants.OneSignalExternalIdPrefix + lvm.MyInfo.MyMemberData.MyMember.MemId.ToString()); Then I add a tag for the unit they are a member of, U plus unit identity column OneSignal.User.AddTag(Common.Constants.OneSignalUnitTag, lvm.MyInfo.MyMemberData.MyUnit.UniId.ToString());
Then on the cloud server:
Configuration config = new Configuration();
config.BasePath = "https://onesignal.com/api/v1";
// Configure Bearer token for authorization: app_key
config.AccessToken = "REST API Key from OneSignal account";
var apiInstance = new DefaultApi(config);
var notification = new Notification(appId: ScoutChat.Common.Constants.OneSignalID); // OneSignal app ID
try
{
List
bool useFilter = true; // I toggle this to test sending by member ID or by Unit Tag; both ways work
if (useFilter)
notification.Filters = filters;
else
{
notification.IncludeExternalUserIds = exUserIds;
}
// Create notification
CreateNotificationSuccessResponse result = apiInstance.CreateNotification(notification);
if (result.Recipients == 0)
Debug.WriteLine("No recipients"); // I find this happens even when the notifications are sent
Debug.WriteLine(result);
}
catch (ApiException ex)
{
Debug.Print("Exception when calling DefaultApi.CreateNotification: " + ex.Message);
Debug.Print("Status Code: " + ex.ErrorCode);
Debug.Print(ex.StackTrace);
}
Hello, we are having this issue as well, are you open to merging a PR? So we just change it to a dictionary and resolve this issue?
What issue are you having? The OneSignal folks agreed that the deprecation warning is a mistake and will be corrected so I'm not worried about that. I find everything else works except: When the app is closed clicking on the notification opens the app but the Clicked event is not called. I have opened an issue for that and submitted example code.
How can we help?
Previously I was using IncludeExternalUserIds to send notification to the certain external user/s, but from the newest version, this Datamember is marked as deprecated.
When I'm trying to use aliases I have some problems with it. I'm not sure how to create them (is it available on the FE side like it was for setting up of externalUserIds?)![image](https://github.com/OneSignal/onesignal-dotnet-api/assets/22717959/e28688de-94cc-4209-82ab-35526fba063d)
Also in documentation there is a mention about visibility of aliases in OneSignal Dashboard but I can't find these.
My actual code looks like this:
and I don't know what should I pass to aliasLabel <- and where to create this if I want the same label for all users but send notifications by their externalId.
Code of Conduct