Ruby Client SDK

The OneSignal Ruby client is a server OneSignal SDK for Ruby. Integrate OneSignal with your backend events, data, and more.

🚧

Backend SDKs in User Model Beta

You still can try using new User Model endpoints, we advise customers to not use these SDKs in production.

Ruby Client SDK

OneSignal - the Ruby gem for the OneSignal

Click to view the latest release version.

Installation

Add this line to your application's Gemfile:

gem 'onesignal', '~> 1.0.1'

And then execute:

$ bundle

Or install with:

$ gem install onesignal

Or install from Github:

$ gem "onesignal", '~> 1.0.1', git: 'git://github.com/OneSignal/onesignal-ruby-api.git'

Getting Started

Please follow the installation procedure and then run the following code:

require 'onesignal'

# setup authorization
OneSignal.configure do |config|
  # Configure Bearer authorization: app_key
  config.user_key = 'YOUR_USER_KEY' # Change this
  config.app_key = 'YOUR_API_KEY'
end

api_instance = OneSignal::DefaultApi.new
notification = OneSignal::Notification.new({app_id: 'YOUR APP ID'}) # Notification

begin
  # Create notification
  result = api_instance.create_notification(notification)
  p result
rescue OneSignal::ApiError => e
  puts "Error when calling DefaultApi->create_notification: #{e}"
end

Documentation for Authorization

app_key

  • Type: Bearer authentication
OneSignal.configure do |config|
  config.app_key = 'APP_KEY' # replace with your api key
end

user_key

  • Type: Bearer authentication
OneSignal.configure do |config|
  config.user_key = 'USER_KEY' # replace with your user key
end

Documentation for API Endpoints

All URIs are relative to https://onesignal.com/api/v1

ClassMethodHTTP requestDescription
OneSignal::DefaultApibegin_live_activityPOST /apps/{app_id}/live_activities/{activity_id}/tokenStart Live Activity
OneSignal::DefaultApicancel_notificationDELETE /notifications/{notification_id}Stop a scheduled or currently outgoing notification
OneSignal::DefaultApicreate_appPOST /appsCreate an app
OneSignal::DefaultApicreate_notificationPOST /notificationsCreate notification
OneSignal::DefaultApicreate_playerPOST /playersAdd a device
OneSignal::DefaultApicreate_segmentsPOST /apps/{app_id}/segmentsCreate Segments
OneSignal::DefaultApicreate_subscriptionPOST /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions
OneSignal::DefaultApicreate_userPOST /apps/{app_id}/users
OneSignal::DefaultApidelete_aliasDELETE /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete}
OneSignal::DefaultApidelete_playerDELETE /players/{player_id}Delete a user record
OneSignal::DefaultApidelete_segmentsDELETE /apps/{app_id}/segments/{segment_id}Delete Segments
OneSignal::DefaultApidelete_subscriptionDELETE /apps/{app_id}/subscriptions/{subscription_id}
OneSignal::DefaultApidelete_userDELETE /apps/{app_id}/users/by/{alias_label}/{alias_id}
OneSignal::DefaultApiend_live_activityDELETE /apps/{app_id}/live_activities/{activity_id}/token/{subscription_id}Stop Live Activity
OneSignal::DefaultApiexport_playersPOST /players/csv_export?app_id={app_id}CSV export
OneSignal::DefaultApifetch_aliasesGET /apps/{app_id}/subscriptions/{subscription_id}/user/identity
OneSignal::DefaultApifetch_userGET /apps/{app_id}/users/by/{alias_label}/{alias_id}
OneSignal::DefaultApifetch_user_identityGET /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity
OneSignal::DefaultApiget_appGET /apps/{app_id}View an app
OneSignal::DefaultApiget_appsGET /appsView apps
OneSignal::DefaultApiget_eligible_iamsGET /apps/{app_id}/subscriptions/{subscription_id}/iams
OneSignal::DefaultApiget_notificationGET /notifications/{notification_id}View notification
OneSignal::DefaultApiget_notification_historyPOST /notifications/{notification_id}/historyNotification History
OneSignal::DefaultApiget_notificationsGET /notificationsView notifications
OneSignal::DefaultApiget_outcomesGET /apps/{app_id}/outcomesView Outcomes
OneSignal::DefaultApiget_playerGET /players/{player_id}View device
OneSignal::DefaultApiget_playersGET /playersView devices
OneSignal::DefaultApiidentify_user_by_aliasPATCH /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity
OneSignal::DefaultApiidentify_user_by_subscription_idPATCH /apps/{app_id}/subscriptions/{subscription_id}/user/identity
OneSignal::DefaultApitransfer_subscriptionPATCH /apps/{app_id}/subscriptions/{subscription_id}/owner
OneSignal::DefaultApiupdate_appPUT /apps/{app_id}Update an app
OneSignal::DefaultApiupdate_live_activityPOST /apps/{app_id}/live_activities/{activity_id}/notificationsUpdate a Live Activity via Push
OneSignal::DefaultApiupdate_playerPUT /players/{player_id}Edit device
OneSignal::DefaultApiupdate_player_tagsPUT /apps/{app_id}/users/{external_user_id}Edit tags with external user id
OneSignal::DefaultApiupdate_subscriptionPATCH /apps/{app_id}/subscriptions/{subscription_id}
OneSignal::DefaultApiupdate_userPATCH /apps/{app_id}/users/by/{alias_label}/{alias_id}

Documentation for Models