Skip to content

Create notification with include_aliases failed #38

Description

@kienvtqhi

How can we help?

Hello,

I am using create notification API with included_aliases to send the notification to the specified user by external_id.

aliasExternalIds := &onesignal.PlayerNotificationTargetIncludeAliases{
		AdditionalProperties: map[string]interface{}{
			"external_id": []string{receiverId},
		},
	}

notification.IncludeAliases = *onesignal.NewNullablePlayerNotificationTargetIncludeAliases(aliasExternalIds)

notification.IncludeExternalUserIds = []string{receiverId}

	targeChannel := "push"
	notification.TargetChannel = &targeChannel
	// notification.IncludedSegments = []string{"Total Subscriptions"}

	var iosBadgeCount *int32 = new(int32)
	*iosBadgeCount = 1
	notification.IosBadgeCount = *onesignal.NewNullableInt32(iosBadgeCount)

	iosBadgeType := "Increase"
	notification.IosBadgeType = *onesignal.NewNullableString(&iosBadgeType)

	appAuth := context.WithValue(context.Background(), onesignal.AppAuth, nd.oneSignalConfig.RestApiKey)

	successResponse, _, err := nd.oneSignalApiClient.DefaultApi.CreateNotification(appAuth).Notification(notification).Execute()

But it is failed. It return the invalid_aliases.

{
    "id": "b15ba6e5-2223-49d6-9eda-684b9051f5a8",
    "external_id": null,
    "errors": {
        "invalid_aliases": {
            "external_id": [
                "bnudasdfRUt4yUJh0912E63tzIXPsxq1"
            ]
        }
    }
}

What's wrong?
Please help me to fix it.

Thank you so much!

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions