Created
December 6, 2022 14:54
-
-
Save gitfvb/c60aa0430071a0bbf8126f4b1352185e to your computer and use it in GitHub Desktop.
Sending Push Notification through PowerShell and Google/Firebase Cloud messaging API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$params = [Hashtable]@{ | |
"Uri" = "https://fcm.googleapis.com/fcm/send" | |
"Method" = "POST" | |
"ContentType" = "application/json" | |
"Headers" = [Hashtable]@{ | |
"Authorization" = "key=AAAAWqJ3X..." | |
} | |
"Body" = (ConvertTo-Json -InputObject ( | |
[PSCustomObject]@{ | |
"data"=[PSCustomObject]@{ | |
"title"="Hello" | |
"message"="World" | |
} | |
"notification" = [PSCustomObject]@{ | |
"title" = "Breaking News" | |
"body" = "New news story available." | |
"click_action" = "HANDLE_BREAKING_NEWS" | |
} | |
"to"="f-X8-Bsg_UsNl0dxPX2dDN:..." | |
})) | |
} | |
#exit 0 | |
Invoke-RestMethod @params | |
# For PSCore/Pwsh use the additional flag `-SkipHeaderValidation` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment