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

[Bug]: Do not receive notification using externalId #87

Open
1 task done
Duddde opened this issue Jan 11, 2024 · 5 comments
Open
1 task done

[Bug]: Do not receive notification using externalId #87

Duddde opened this issue Jan 11, 2024 · 5 comments

Comments

@Duddde
Copy link

Duddde commented Jan 11, 2024

What happened?

I'm trying to send notification with ExternalId.
I do not receive anything.
But when the external Id is null, i receive the notification on my device.

 public async Task SendNewMatchNotification(string userId)
  {
      //SendOneSignalNotification
      Configuration config = new Configuration();
      config.BasePath = _options.BasePath;
      // Configure Bearer token for authorization: app_key
      config.AccessToken = _options.AccessToken;
      
      var apiInstance = new DefaultApi(config);
      
      var notification = new Notification(appId: _options.AppId)
      {
          TemplateId = _options.NewMatchTemplateId,
          IncludedSegments = new List<string> { "Total Subscriptions" },
          ExternalId = userId
      };
      
      try
      {
          // Create notification
          CreateNotificationSuccessResponse result = await apiInstance.CreateNotificationAsync(notification);
          Debug.WriteLine(result);
      }
      catch (ApiException e)
      {
          Debug.Print("Exception when calling DefaultApi.CreateNotification: " + e.Message);
          Debug.Print("Status Code: " + e.ErrorCode);
          Debug.Print(e.StackTrace);
      }
  }

On my .Net MAUI APP i'm using OneSignal.Login(userId.ToString()); to register the connected user.

But in my subscriptions i have two with the same Id's (it's maybe the problem)

image

Any idea of what's the problem ?

Steps to reproduce?

Back end API .Net 7
pckg OneSignalAPI v2.0.2

Client : MAUI .Net 7.0
pckg OneSignal.SDK.Net 5.0.2

What did you expect to happen?

I expect to receive notification when using externalId

Relevant log output

Output of the one signal api : 
class CreateNotificationSuccessResponse {
  Id: 4cead680-2811-4134-b570-4f4d1bd95acc
  Recipients: 0
  ExternalId: 91b0045a-ed5c-49df-b499-88d382721db4
  Errors: 
}

Code of Conduct

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

Duddde commented Jan 11, 2024

According to OneSignal Support, I need to use the IncludeExternalUserIds property instead of ExternalId. Indeed it seems to work. However, the IncludeExternalUserIds property is marked as deprecated by the SDK.
Do you think this is the right solution?

The API return does not looks good...

class CreateNotificationSuccessResponse {
Id: 9481f102-ae46-4bfa-907e-fa8949a00aed
Recipients: 0
ExternalId:
Errors:
}

@tulio-mcsantos
Copy link

Accordingly with their documentation it is supposed to use the include_aliases property but I could not make it work with it. My Notification:

Notification notification = new(appId: "<MY_APP_ID>")
{
    IncludeAliases = new PlayerNotificationTargetIncludeAliases(["<EXTERNAL_ID>"]),
    TargetChannel = Notification.TargetChannelEnum.Push,
    Contents = new StringMap(en: "Hello world from .NET"),
    Subtitle = new StringMap(en: "Testing"),
};

Response:

class CreateNotificationSuccessResponse {
  Id: 
  Recipients: 0
  ExternalId: 
  Errors: class Notification200Errors {
  ActualInstance: System.Collections.Generic.List`1[System.String]
}

But using the deprecated IncludeExternalUserIds it did work:

Notification notification = new(appId: "<MY_APP_ID>")
{
    IncludeExternalUserIds = ["<EXTERNAL_ID>"],
    TargetChannel = Notification.TargetChannelEnum.Push,
    Contents = new StringMap(en: "Hello world from .NET"),
    Subtitle = new StringMap(en: "Testing"),
};

But it does have a kind of weird response:

class CreateNotificationSuccessResponse {
  Id: f1266639-78e0-477e-9977-48a223b410e2
  Recipients: 0
  ExternalId: 
  Errors: 
}

@emawby
Copy link
Contributor

emawby commented Jan 17, 2024

@Duddde Thank you for reporting. I am going to move this issue to the .net api Github repository since I believe this is an issue with the backend SDK and not this repo. To confirm are you able to receive the notification when you create the push notification using the web dashboard or using the REST API directly?

@Duddde
Copy link
Author

Duddde commented Jan 18, 2024

Thanks for your feedback. Yes i'm able to receive notifications from the dashboard or my API.

@DaveBrask
Copy link

I've previously chased this down with OneSignal support, and the deprecation messages are a mistake. IncludeExternalUserIds is the correct way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants