Created
May 21, 2019 17:28
-
-
Save 0xDing/6b2191b80c984b2255259187c5036aaf to your computer and use it in GitHub Desktop.
visual studio app center push notifications ruby sdk
This file contains hidden or 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
# frozen_string_literal: true | |
class MicrosoftAppcenterPushService | |
include HTTParty | |
base_uri 'https://appcenter.ms/api/v0.1/apps' | |
OWNER = 'your org name' | |
APP_NAME = 'your app name' | |
def initialize | |
@header = { | |
'Content-Type': 'application/json; charset=UTF-8', | |
'X-API-Token': ENV['MS_APPCENTER_TOKEN'] | |
} | |
puts @header | |
end | |
def push_notification(message, target=null) | |
self.class.post("/#{OWNER}/#{APP_NAME}/push/notifications", | |
headers: @header, | |
body: { | |
notification_content: message, | |
notification_target: target | |
}.to_json | |
) | |
end | |
# push notification to specified user | |
def push_notification_to(user_ids,message) | |
push_notification(message,{ | |
type: 'user_ids_target', | |
user_ids: user_ids | |
}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment