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

add GetAps #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions payload/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,44 @@ func (p *Payload) MarshalJSON() ([]byte, error) {
func (p *Payload) aps() *aps {
return p.content["aps"].(*aps)
}
func GetAps(data map[string]interface{}) *aps {
Copy link

@valeriikundas valeriikundas Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe aps should be made public for this to be used in caller

a := &aps{}
for k, v := range data {
switch k {
case "alert":
a.Alert = v
break
case "badge":
a.Badge = v
break
case "category":
a.Category = v.(string)
break
case "content-available":
a.ContentAvailable = v.(int)
break
case "interruption-level":
a.InterruptionLevel = (EInterruptionLevel)(v.(string))
break
case "mutable-content":
a.MutableContent = v.(int)
break
case "relevance-score":
a.RelevanceScore = v
break
case "sound":
a.Sound = v
break
case "thread-id":
a.ThreadID = v.(string)
break
case "url-args":
a.URLArgs = v.([]string)
break
}
}
return a
}

func (a *aps) alert() *alert {
if _, ok := a.Alert.(*alert); !ok {
Expand Down