Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

NotificationRequest.Tags not used? #5

Open
gfl-chris opened this issue Jan 17, 2018 · 2 comments
Open

NotificationRequest.Tags not used? #5

gfl-chris opened this issue Jan 17, 2018 · 2 comments

Comments

@gfl-chris
Copy link

gfl-chris commented Jan 17, 2018

I can't find a reference to NotificationRequest's Tags field (JSON: tags) in the Onesignal documentation and support tells me that tag values can't be set when creating a notification (when sending a templated notification). What was/is the intended behaviour? Has this been working for anyone else?

@UpToEleven1102
Copy link

UpToEleven1102 commented Dec 18, 2018

Did you manage to make it work yet?

Here is my code
notificationReq := &onesignal.NotificationRequest{ AppID: appID, Contents: map[string]string{"en": "English message"}, IsAndroid: true, Tags: map[string]string{ "role": "merchant", }, }

And the error

2018/12/18 00:18:31 OneSignal returned those error messages:

  • Tags must be an array. For example, [{"key":"gender","relation":"=","value":"male"}]
    exit status 1

@sergolius
Copy link

@gfl-chris notification by template works fine for me.
@UpToEleven1102 you need to format tags properly (map inside slice of interfaces), here is sample of tags formatting:

onesignal.NotificationRequest{
	TemplateID: "TemplateID",
	Tags: []interface{}{
		map[string]interface{}{
			"key": "gender", "relation": "=", "value": "male",
		},
	},
	AppID:            appID,
	IncludePlayerIDs: IncludePlayerIDs,
	//Contents:         map[string]string{"en": "hello"},
}

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

No branches or pull requests

3 participants