The twinpush gem lets your ruby backend manage TWINPUSH notifications.
$ gem install twinpush
or in your Gemfile
just include it:
gem 'twinpush'
Tested in Ruby versions:
2.3.8
To send a notification to one or more devices, you must first initialise a new TWINPUSH class with your TWINPUSH credentials and then call the create method.
Creates a new notification to be delivered from the platform (See more):
require 'twinpush'
twinpush = TWINPUSH.new(app_id: 'cs555ab2356a37a0',
subdomain: 'subdomain-test',
api_token: "1c5cabc4055e03c64f123d9dbfb4d0e9",
api_token_creator: "ca044e0bc6a4f1cg23d9dbfb4251dhy6")
twinpush.create({"broadcast": true,
"title": "Welcome to TwinPush",
"alert": "This is the message displayed in Notifications Center",
"url": "https://www.inception-explained.com",
"custom_properties": {"key1": "value1", "key2": "value2"},
"badge": "+1",
"delivery_speed": "slow",
"sound": "waves",
"send_since": "2015-10-10 15:14:33 +0000",
"tags": ["one", "two"],
"group_name": "Commercial Offers"})
Response
{
"body" => {
"objects" => [
[0] {
"id" => "f637304cf8c453e5",
"sound" => "waves",
"alert" => "This is the message displayed in Notifications Center",
"title" => "Welcome to TwinPush",
"badge" => "+1",
"custom_properties" => {
"key1" => "value1",
"key2" => "value2"
},
"tp_rich_url" => "https://www.inception-explained.com",
"delivery_speed" => "slow",
"name" => nil,
"group_name" => "Commercial Offers",
"protected_content" => false,
"send_since" => "2015-10-10 15:14:33 UTC",
"tags" => [
[0] "one",
[1] "two",
[2] "tp_rich"
],
"type" => "Notification"
}
],
"references" => []
},
"headers" => { ... },
"status_code" => 200,
"response" => "success"
}
Obtains details from a previously created notification. See more