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

[question]: Aliases, IncludeExternalUserIds as deprecated. #34

Open
1 task done
pmikoda opened this issue Jun 1, 2023 · 16 comments
Open
1 task done

[question]: Aliases, IncludeExternalUserIds as deprecated. #34

pmikoda opened this issue Jun 1, 2023 · 16 comments
Labels
bug Something isn't working

Comments

@pmikoda
Copy link

pmikoda commented Jun 1, 2023

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

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:
image
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

  • I agree to follow this project's Code of Conduct
@emawby
Copy link

emawby commented Jun 12, 2023

@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.

@mjasikowski
Copy link

mjasikowski commented Jun 16, 2023

@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.

@ante-maric
Copy link

I just bumped into this too :(

@emawby
Copy link

emawby commented Jun 22, 2023

@yasikovsky Thank you for pointing this out we will address!

@emawby emawby added the bug Something isn't working label Jun 22, 2023
@temcewen
Copy link

@emawby
This is a severe issue. I suppose we should just continue using "IncludeExternalUserIds" until it's fixed, correct?

@temcewen
Copy link

Any updates on this?

@nan-li
Copy link

nan-li commented Aug 17, 2023

This is a bug we are fixing. In the meantime, it is safe to continue using IncludeExternalUserIds @temcewen

@grantvine-sc
Copy link

Has this since been resolved ?

@nan-li
Copy link

nan-li commented Feb 1, 2024

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.

@matheuscschenfeld
Copy link

Any news about this issue?

@DaveBrask
Copy link

I find that IncludeExternalUserIds works for me, and I plan on using it in production. Soon. Is that a bad idea?

@matheuscschenfeld
Copy link

matheuscschenfeld commented Mar 15, 2024

@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.

@DaveBrask
Copy link

@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.

@DaveBrask
Copy link

@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 exUserIds = new List();
exUserIds.Add(ScoutChat.Common.Constants.OneSignalExternalIdPrefix + "60"); // 60 is my member number
notification.Headings = new StringMap("Title");
notification.Contents = new StringMap("Contents");
notification.ChannelForExternalUserIds = ""push"";
Dictionary<string, object> dataDict = new Dictionary<string, object>();
notification.Data = dataDict;
List filters = new List(); // field, key, value
int unitId = 1; // 1 is my unit number
Filter filter = new Filter("tag", ScoutChat.Common.Constants.OneSignalUnitTag, unitId.ToString());
filters.Add(filter);

            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
            {

#pragma warning disable CS0612 // Type or member is obsolete
notification.IncludeExternalUserIds = exUserIds;
#pragma warning restore CS0612 // Type or member is obsolete
}
// 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);
}

@JakubHolovsky
Copy link

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?

@DaveBrask
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants