firebase-admin-sdk 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -21
- data/firebase-admin-sdk.gemspec +1 -0
- data/lib/firebase-admin-sdk.rb +21 -1
- data/lib/firebase/admin/app.rb +0 -6
- data/lib/firebase/admin/auth/client.rb +8 -0
- data/lib/firebase/admin/auth/token_verifier.rb +1 -1
- data/lib/firebase/admin/auth/user_info.rb +6 -6
- data/lib/firebase/admin/auth/user_manager.rb +2 -2
- data/lib/firebase/admin/auth/user_record.rb +5 -5
- data/lib/firebase/admin/config.rb +4 -2
- data/lib/firebase/admin/internal/http_client.rb +1 -0
- data/lib/firebase/admin/messaging/android_config.rb +77 -0
- data/lib/firebase/admin/messaging/android_fcm_options.rb +19 -0
- data/lib/firebase/admin/messaging/android_notification.rb +221 -0
- data/lib/firebase/admin/messaging/apns_config.rb +38 -0
- data/lib/firebase/admin/messaging/apns_fcm_options.rb +27 -0
- data/lib/firebase/admin/messaging/apns_payload.rb +28 -0
- data/lib/firebase/admin/messaging/aps.rb +82 -0
- data/lib/firebase/admin/messaging/aps_alert.rb +110 -0
- data/lib/firebase/admin/messaging/client.rb +181 -0
- data/lib/firebase/admin/messaging/critical_sound.rb +37 -0
- data/lib/firebase/admin/messaging/error.rb +36 -0
- data/lib/firebase/admin/messaging/error_info.rb +25 -0
- data/lib/firebase/admin/messaging/fcm_options.rb +19 -0
- data/lib/firebase/admin/messaging/light_settings.rb +34 -0
- data/lib/firebase/admin/messaging/message.rb +83 -0
- data/lib/firebase/admin/messaging/message_encoder.rb +355 -0
- data/lib/firebase/admin/messaging/multicast_message.rb +67 -0
- data/lib/firebase/admin/messaging/notification.rb +34 -0
- data/lib/firebase/admin/messaging/topic_management_response.rb +41 -0
- data/lib/firebase/admin/messaging/utils.rb +78 -0
- data/lib/firebase/admin/version.rb +1 -1
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123d6d32ec877dc2478f43d37762c2fad6dee697d21bc746dbd63d16c7688ab0
|
4
|
+
data.tar.gz: 9a4decd758386fb6c87ad73607d949842f7a7f2e659b6d6fe659f62d0bdd0d40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c806d219be3867c552aff868f296854ac0a348fa9d9c04063c874e201810dda370a63b7fb425d38fe2bbfe8af13043bcef8cef632a2f888eca547bfa48815dbc
|
7
|
+
data.tar.gz: 7c187c93c943c8dbc352cf153f82d45fb27b1cd1febde4773c7e5cc3cdbb5492848c051afd96f139c2af4e7b6fad3bce11cd86e5fa280155d8d434286d36d841
|
data/README.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
# Firebase
|
1
|
+
# Firebase::Admin::Sdk
|
2
2
|
|
3
|
-
|
4
|
-
in Ruby.
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/firebase/admin/sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
|
5
4
|
|
6
|
-
|
7
|
-
[Firebase Admin SDK setup guide](https://firebase.google.com/docs/admin/setup/).
|
8
|
-
|
9
|
-
This gem is currently in alpha and not recommended for production use (yet).
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
10
6
|
|
11
7
|
## Installation
|
12
8
|
|
@@ -26,27 +22,22 @@ Or install it yourself as:
|
|
26
22
|
|
27
23
|
## Usage
|
28
24
|
|
29
|
-
|
25
|
+
TODO: Write usage instructions here
|
30
26
|
|
31
|
-
|
32
|
-
gem 'firebase-admin-sdk'
|
27
|
+
## Development
|
33
28
|
|
34
|
-
|
35
|
-
```
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
gem 'firebase-admin-sdk'
|
41
|
-
|
42
|
-
creds = Firebase::Admin::Credentials.from_file('service_account.json')
|
43
|
-
app = Firebase::Admin::App.new(credentials: creds)
|
44
|
-
```
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
45
32
|
|
46
33
|
## Contributing
|
47
34
|
|
48
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/firebase-admin-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/firebase-admin-sdk/blob/master/CODE_OF_CONDUCT.md).
|
49
36
|
|
50
37
|
## License
|
51
38
|
|
52
39
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Firebase::Admin::Sdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/firebase-admin-sdk/blob/master/CODE_OF_CONDUCT.md).
|
data/firebase-admin-sdk.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "googleauth", "~> 0.16.2"
|
25
25
|
spec.add_runtime_dependency "faraday", "< 2"
|
26
26
|
spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
|
27
|
+
spec.add_runtime_dependency "hashie", "~> 4.1"
|
27
28
|
spec.add_runtime_dependency "jwt", ">= 1.5", "< 3.0"
|
28
29
|
|
29
30
|
spec.add_development_dependency "rake", "~> 13.0"
|
data/lib/firebase-admin-sdk.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative "firebase/admin/error"
|
|
5
5
|
require_relative "firebase/admin/config"
|
6
6
|
require_relative "firebase/admin/gce"
|
7
7
|
require_relative "firebase/admin/credentials"
|
8
|
+
require_relative "firebase/admin/app"
|
8
9
|
require_relative "firebase/admin/internal/http_client"
|
9
10
|
require_relative "firebase/admin/auth/error"
|
10
11
|
require_relative "firebase/admin/auth/utils"
|
@@ -14,4 +15,23 @@ require_relative "firebase/admin/auth/user_info"
|
|
14
15
|
require_relative "firebase/admin/auth/user_record"
|
15
16
|
require_relative "firebase/admin/auth/user_manager"
|
16
17
|
require_relative "firebase/admin/auth/client"
|
17
|
-
require_relative "firebase/admin/
|
18
|
+
require_relative "firebase/admin/messaging/error"
|
19
|
+
require_relative "firebase/admin/messaging/android_config"
|
20
|
+
require_relative "firebase/admin/messaging/android_fcm_options"
|
21
|
+
require_relative "firebase/admin/messaging/android_notification"
|
22
|
+
require_relative "firebase/admin/messaging/apns_config"
|
23
|
+
require_relative "firebase/admin/messaging/apns_fcm_options"
|
24
|
+
require_relative "firebase/admin/messaging/apns_payload"
|
25
|
+
require_relative "firebase/admin/messaging/aps"
|
26
|
+
require_relative "firebase/admin/messaging/aps_alert"
|
27
|
+
require_relative "firebase/admin/messaging/critical_sound"
|
28
|
+
require_relative "firebase/admin/messaging/fcm_options"
|
29
|
+
require_relative "firebase/admin/messaging/light_settings"
|
30
|
+
require_relative "firebase/admin/messaging/notification"
|
31
|
+
require_relative "firebase/admin/messaging/message"
|
32
|
+
require_relative "firebase/admin/messaging/utils"
|
33
|
+
require_relative "firebase/admin/messaging/message_encoder"
|
34
|
+
require_relative "firebase/admin/messaging/multicast_message"
|
35
|
+
require_relative "firebase/admin/messaging/error_info"
|
36
|
+
require_relative "firebase/admin/messaging/topic_management_response"
|
37
|
+
require_relative "firebase/admin/messaging/client"
|
data/lib/firebase/admin/app.rb
CHANGED
@@ -23,12 +23,6 @@ module Firebase
|
|
23
23
|
@service_account_id = @config.service_account_id
|
24
24
|
@project_id = @config.project_id || @credentials.project_id
|
25
25
|
end
|
26
|
-
|
27
|
-
# Gets the auth client for this App.
|
28
|
-
# @return [Firebase::Admin::Auth::Client]
|
29
|
-
def auth
|
30
|
-
@auth_client ||= Auth::Client.new(self)
|
31
|
-
end
|
32
26
|
end
|
33
27
|
end
|
34
28
|
end
|
@@ -78,7 +78,7 @@ module Firebase
|
|
78
78
|
def decode_unsigned(token)
|
79
79
|
raise InvalidTokenError, "token must not be nil" unless token
|
80
80
|
raise InvalidTokenError, "token must be a string" unless token.is_a?(String)
|
81
|
-
raise InvalidTokenError, "The auth emulator only accepts unsigned ID tokens."
|
81
|
+
raise InvalidTokenError, "The auth emulator only accepts unsigned ID tokens." unless token.split(".").length == 2
|
82
82
|
options = decode_options.merge({algorithm: "none"})
|
83
83
|
JWT.decode(token, nil, false, options)
|
84
84
|
end
|
@@ -17,27 +17,27 @@ module Firebase
|
|
17
17
|
|
18
18
|
# Gets the ID of this user.
|
19
19
|
def uid
|
20
|
-
@data
|
20
|
+
@data.fetch(:rawId)
|
21
21
|
end
|
22
22
|
|
23
23
|
# Gets the display name of this user.
|
24
24
|
def display_name
|
25
|
-
@data
|
25
|
+
@data.fetch(:displayName)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Gets the email address associated with this user.
|
29
29
|
def email
|
30
|
-
@data
|
30
|
+
@data.fetch(:email)
|
31
31
|
end
|
32
32
|
|
33
33
|
# Gets the phone number associated with this user.
|
34
34
|
def phone_number
|
35
|
-
@data
|
35
|
+
@data.fetch(:phoneNumber)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Gets the photo url of this user.
|
39
39
|
def photo_url
|
40
|
-
@data
|
40
|
+
@data.fetch(:photoUrl)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Gets the id of the identity provider.
|
@@ -45,7 +45,7 @@ module Firebase
|
|
45
45
|
# This can be a short domain name (e.g. google.com), or the identity of an OpenID
|
46
46
|
# identity provider.
|
47
47
|
def provider_id
|
48
|
-
@data
|
48
|
+
@data.fetch(:providerId)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Converts the object into a hash.
|
@@ -43,7 +43,7 @@ module Firebase
|
|
43
43
|
disabled: to_boolean(disabled)
|
44
44
|
}.compact
|
45
45
|
res = @client.post(with_path("accounts"), payload).body
|
46
|
-
uid = res&.fetch(
|
46
|
+
uid = res&.fetch(:localId)
|
47
47
|
raise CreateUserError, "failed to create user #{res}" if uid.nil?
|
48
48
|
get_user_by(uid: uid)
|
49
49
|
end
|
@@ -67,7 +67,7 @@ module Firebase
|
|
67
67
|
raise ArgumentError, "Unsupported query: #{query}"
|
68
68
|
end
|
69
69
|
res = @client.post(with_path("accounts:lookup"), payload).body
|
70
|
-
users = res[
|
70
|
+
users = res[:users] if res
|
71
71
|
UserRecord.new(users[0]) if users.is_a?(Array) && users.length > 0
|
72
72
|
end
|
73
73
|
|
@@ -7,7 +7,7 @@ module Firebase
|
|
7
7
|
class UserRecord < UserInfo
|
8
8
|
# Gets the ID of this user.
|
9
9
|
def uid
|
10
|
-
@data
|
10
|
+
@data.fetch(:localId)
|
11
11
|
end
|
12
12
|
|
13
13
|
# Gets the id of the identity provider.
|
@@ -18,11 +18,11 @@ module Firebase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def email_verified?
|
21
|
-
!!@data
|
21
|
+
!!@data.fetch(:emailVerified)
|
22
22
|
end
|
23
23
|
|
24
24
|
def disabled?
|
25
|
-
!!@data
|
25
|
+
!!@data.fetch(:disabled)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Gets the time, in milliseconds since the epoch, before which tokens are invalid.
|
@@ -49,13 +49,13 @@ module Firebase
|
|
49
49
|
#
|
50
50
|
# @return [Array of UserInfo]
|
51
51
|
def provider_data
|
52
|
-
providers = @data
|
52
|
+
providers = @data.fetch(:providerUserInfo) || []
|
53
53
|
providers.to_a.map { |p| UserInfo.new(p) }
|
54
54
|
end
|
55
55
|
|
56
56
|
# Gets any custom claims set on this user account.
|
57
57
|
def custom_claims
|
58
|
-
claims = @data
|
58
|
+
claims = @data.fetch(:customAttributes)
|
59
59
|
parsed = JSON.parse(claims) unless claims.nil?
|
60
60
|
parsed if parsed.is_a?(Hash) && !parsed.empty?
|
61
61
|
end
|
@@ -42,8 +42,10 @@ module Firebase
|
|
42
42
|
# @return [Firebase::Admin::Config]
|
43
43
|
def from_json(json)
|
44
44
|
data = JSON.parse(json)
|
45
|
-
new(
|
46
|
-
|
45
|
+
new(
|
46
|
+
project_id: data["projectId"],
|
47
|
+
service_account_id: data["serviceAccountId"]
|
48
|
+
)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -58,6 +58,7 @@ module Firebase
|
|
58
58
|
c.use CredentialsMiddleware, credentials: @credentials unless @credentials.nil?
|
59
59
|
c.use Faraday::Request::UrlEncoded
|
60
60
|
c.use FaradayMiddleware::EncodeJson
|
61
|
+
c.use FaradayMiddleware::Mashify
|
61
62
|
c.use Faraday::Response::ParseJson
|
62
63
|
c.use Faraday::Response::RaiseError
|
63
64
|
c.adapter(Faraday.default_adapter)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Firebase
|
2
|
+
module Admin
|
3
|
+
module Messaging
|
4
|
+
# Android-specific options that can be included in a {Message}.
|
5
|
+
class AndroidConfig
|
6
|
+
# @return [String, nil]
|
7
|
+
# Collapse key string for the message.
|
8
|
+
# This is an identifier for a group of messages that can be collapsed, so that only the last message is sent
|
9
|
+
# when delivery can be resumed. A maximum of 4 different collapse keys may be active at a given time.
|
10
|
+
attr_accessor :collapse_key
|
11
|
+
|
12
|
+
# @return [String, nil]
|
13
|
+
# Priority of the message. Must be either `high` or `normal`.
|
14
|
+
attr_accessor :priority
|
15
|
+
|
16
|
+
# @return [Numeric, nil]
|
17
|
+
# Time-to-live duration of the message in seconds.
|
18
|
+
attr_accessor :ttl
|
19
|
+
|
20
|
+
# @return [String, nil]
|
21
|
+
# Package name of the application where the registration tokens must match in order to receive the message.
|
22
|
+
attr_accessor :restricted_package_name
|
23
|
+
|
24
|
+
# @return [Hash{String,Symbol => String}, nil]
|
25
|
+
# A hash of data fields to be included in the message. All keys and values must be strings.
|
26
|
+
# When provided, overrides any data fields set on the top-level message.
|
27
|
+
attr_accessor :data
|
28
|
+
|
29
|
+
# @return [AndroidNotification, nil]
|
30
|
+
# Android notification to be included in the message.
|
31
|
+
attr_accessor :notification
|
32
|
+
|
33
|
+
# @return [AndroidFCMOptions, nil]
|
34
|
+
# Options for features provided by the FCM SDK for Android.
|
35
|
+
attr_accessor :fcm_options
|
36
|
+
|
37
|
+
# Initializes an {AndroidConfig}.
|
38
|
+
#
|
39
|
+
# @param [String, nil] collapse_key
|
40
|
+
# Collapse key string for the message (optional).
|
41
|
+
# @param [String, nil] priority
|
42
|
+
# Priority of the message (optional).
|
43
|
+
# Must be either `high` or `normal`.
|
44
|
+
# @param [Numeric, nil] ttl
|
45
|
+
# The time-to-live duration of the message (optional).
|
46
|
+
# Time-to-live duration of the message in seconds.
|
47
|
+
# @param [String, nil] restricted_package_name
|
48
|
+
# The package name of the application where the registration tokens must match in order to receive
|
49
|
+
# the message (optional).
|
50
|
+
# @param [Hash{String,Symbol => String}, nil] data
|
51
|
+
# A hash of data fields to be included in the message (optional).
|
52
|
+
# All keys and values must be strings.
|
53
|
+
# @param [AndroidNotification, nil] notification
|
54
|
+
# An {AndroidNotification} to be included in the message (optional).
|
55
|
+
# @param [AndroidFCMOptions, nil] fcm_options
|
56
|
+
# An {AndroidFCMOptions} to be included in the message (optional).
|
57
|
+
def initialize(
|
58
|
+
collapse_key: nil,
|
59
|
+
priority: nil,
|
60
|
+
ttl: nil,
|
61
|
+
restricted_package_name: nil,
|
62
|
+
data: nil,
|
63
|
+
notification: nil,
|
64
|
+
fcm_options: nil
|
65
|
+
)
|
66
|
+
self.collapse_key = collapse_key
|
67
|
+
self.priority = priority
|
68
|
+
self.ttl = ttl
|
69
|
+
self.restricted_package_name = restricted_package_name
|
70
|
+
self.data = data
|
71
|
+
self.notification = notification
|
72
|
+
self.fcm_options = fcm_options
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Firebase
|
2
|
+
module Admin
|
3
|
+
module Messaging
|
4
|
+
# Represents options for features provided by the FCM SDK for Android.
|
5
|
+
class AndroidFCMOptions
|
6
|
+
# @return [String, nil] Label associated with the message's analytics data.
|
7
|
+
attr_accessor :analytics_label
|
8
|
+
|
9
|
+
# Initializes an {AndroidFCMOptions}.
|
10
|
+
#
|
11
|
+
# @param [String, nil] analytics_label
|
12
|
+
# The label associated with the message's analytics data (optional).
|
13
|
+
def initialize(analytics_label: nil)
|
14
|
+
self.analytics_label = analytics_label
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
module Firebase
|
2
|
+
module Admin
|
3
|
+
module Messaging
|
4
|
+
# Android-specific notification options that can be included in an {AndroidConfig}.
|
5
|
+
class AndroidNotification
|
6
|
+
# @return [String, nil]
|
7
|
+
# Title of the Android notification. When provided, overrides the title set via {Notification}.
|
8
|
+
attr_accessor :title
|
9
|
+
|
10
|
+
# @return [String, nil]
|
11
|
+
# Body of the Android notification. When provided, overrides the body set via {Notification}.
|
12
|
+
attr_accessor :body
|
13
|
+
|
14
|
+
# @return [String, nil]
|
15
|
+
# Icon resource for the Android notification.
|
16
|
+
attr_accessor :icon
|
17
|
+
|
18
|
+
# @return [String, nil]
|
19
|
+
# Notification icon color in `#rrggbb` format.
|
20
|
+
attr_accessor :color
|
21
|
+
|
22
|
+
# @return [String, nil]
|
23
|
+
# File name of the sound to be played when the device receives the notification.
|
24
|
+
attr_accessor :sound
|
25
|
+
|
26
|
+
# @return [String, nil]
|
27
|
+
# Notification tag. This is an identifier used to replace existing notifications in the notification drawer.
|
28
|
+
# If not specified, each request creates a new notification.
|
29
|
+
attr_accessor :tag
|
30
|
+
|
31
|
+
# @return [String, nil]
|
32
|
+
# URL of an image to be displayed in the notification.
|
33
|
+
attr_accessor :image
|
34
|
+
|
35
|
+
# @return [String, nil]
|
36
|
+
# Action associated with a user click on the notification. If specified, an activity with a matching
|
37
|
+
# Intent Filter is launched when a user clicks on the notification.
|
38
|
+
attr_accessor :click_action
|
39
|
+
|
40
|
+
# @return [String, nil]
|
41
|
+
# Key of the body string in the app's string resource to use to localize the body text.
|
42
|
+
attr_accessor :body_loc_key
|
43
|
+
|
44
|
+
# @return [Array<String>, nil]
|
45
|
+
# An array of resource keys that will be used in place of the format specifiers in {body_loc_key}.
|
46
|
+
attr_accessor :body_loc_args
|
47
|
+
|
48
|
+
# @return [String, nil]
|
49
|
+
# Key of the title string in the app's string resource to use to localize the title text.
|
50
|
+
attr_accessor :title_loc_key
|
51
|
+
|
52
|
+
# @return [Array<String>, nil]
|
53
|
+
# An array of resource keys that will be used in place of the format specifiers in {title_loc_key}.
|
54
|
+
attr_accessor :title_loc_args
|
55
|
+
|
56
|
+
# @return [String, nil]
|
57
|
+
# The Android notification channel id (new in Android O). The app must create a channel with this channel id
|
58
|
+
# before any notification with this channel id can be received. If you don't send this channel id in the
|
59
|
+
# request, or if the channel id provided has not yet been created by the app, FCM uses the channel id
|
60
|
+
# specified in the app manifest.
|
61
|
+
attr_accessor :channel_id
|
62
|
+
|
63
|
+
# @return [String, nil]
|
64
|
+
# Sets the "ticker" text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the
|
65
|
+
# text that is displayed in the status bar when the notification first arrives.
|
66
|
+
attr_accessor :ticker
|
67
|
+
|
68
|
+
# @return [Boolean, nil]
|
69
|
+
# When set to `false` or unset, the notification is automatically dismissed when the user clicks it in the
|
70
|
+
# panel. When set to `true`, the notification persists even when the user clicks it.
|
71
|
+
attr_accessor :sticky
|
72
|
+
|
73
|
+
# @return [Time, nil]
|
74
|
+
# For notifications that inform users about events with an absolute time reference, sets the time that the
|
75
|
+
# event in the notification occurred. Notifications in the panel are sorted by this time.
|
76
|
+
attr_accessor :event_time
|
77
|
+
|
78
|
+
# @return [Boolean, nil]
|
79
|
+
# Sets whether or not this notification is relevant only to the current device. Some notifications can be
|
80
|
+
# bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend
|
81
|
+
# this notification not be bridged.
|
82
|
+
attr_accessor :local_only
|
83
|
+
|
84
|
+
# @return [String, nil]
|
85
|
+
# Sets the relative priority for this notification. Low-priority notifications may be hidden from the user in
|
86
|
+
# certain situations. Note this priority differs from `AndroidMessagePriority`. This priority is processed by
|
87
|
+
# the client after the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept that
|
88
|
+
# controls when the message is delivered.
|
89
|
+
attr_accessor :priority
|
90
|
+
|
91
|
+
# @return [Array<Numeric>, nil]
|
92
|
+
# Sets the vibration pattern to use. Pass in an array of numeric durations to turn the vibrator on or off. The
|
93
|
+
# first value indicates the duration to wait before turning the vibrator on. The next value indicates the
|
94
|
+
# duration to keep the vibrator on. Subsequent values alternate between duration to turn the vibrator off and
|
95
|
+
# to turn the vibrator on. If `vibrate_timings` is set and `default_vibrate_timings` is set to `true`, the
|
96
|
+
# default value is used instead of the user-specified `vibrate_timings`.
|
97
|
+
attr_accessor :vibrate_timings
|
98
|
+
|
99
|
+
# @return [Boolean, nil]
|
100
|
+
# If set to `true`, use the Android framework's default vibrate pattern for the notification. Default values
|
101
|
+
# are specified in `config.xml`. If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also
|
102
|
+
# set, the default value is used instead of the user-specified `vibrate_timings`.
|
103
|
+
# @see https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml
|
104
|
+
attr_accessor :default_vibrate_timings
|
105
|
+
|
106
|
+
# @return [Boolean, nil]
|
107
|
+
# If set to `true`, use the Android framework's default sound for the notification. Default values are
|
108
|
+
# specified in `config.xml`.
|
109
|
+
# @see https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml
|
110
|
+
attr_accessor :default_sound
|
111
|
+
|
112
|
+
# @return [LightSettings, nil]
|
113
|
+
# Settings to control the notification's LED blinking rate and color if LED is available on the device.
|
114
|
+
# The total blinking time is controlled by the OS.
|
115
|
+
attr_accessor :light_settings
|
116
|
+
|
117
|
+
# @return [Boolean, nil]
|
118
|
+
# If set to `true`, use the Android framework's default LED light settings for the notification. Default
|
119
|
+
# values are specified in `config.xml`. If `default_light_settings` is set to `true` and `light_settings` is
|
120
|
+
# also set, the user-specified `light_settings` is used instead of the default value.
|
121
|
+
# @see https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/config.xml
|
122
|
+
attr_accessor :default_light_settings
|
123
|
+
|
124
|
+
# @return [String, nil]
|
125
|
+
# Sets the visibility of the notification. Must be either `private`, `public`, or `secret`. If unspecified,
|
126
|
+
# defaults to `private`.
|
127
|
+
attr_accessor :visibility
|
128
|
+
|
129
|
+
# @return [Integer, nil]
|
130
|
+
# Sets the number of items this notification represents. May be displayed as a badge count for Launchers that
|
131
|
+
# support badging. For example, this might be useful if you're using just one notification to represent
|
132
|
+
# multiple new messages but you want the count here to represent the number of total new messages. If zero
|
133
|
+
# or unspecified, systems that support badging use the default, which is to increment a number displayed on
|
134
|
+
# the long-press menu each time a new notification arrives.
|
135
|
+
# @see https://developer.android.com/training/notify-user/badges
|
136
|
+
attr_accessor :notification_count
|
137
|
+
|
138
|
+
# Initializes an AndroidNotification
|
139
|
+
#
|
140
|
+
# @param [String, nil] title
|
141
|
+
# @param [String, nil] body
|
142
|
+
# @param [String, nil] icon
|
143
|
+
# @param [String, nil] color
|
144
|
+
# @param [String, nil] sound
|
145
|
+
# @param [String, nil] tag
|
146
|
+
# @param [String, nil] image
|
147
|
+
# @param [String, nil] click_action
|
148
|
+
# @param [String, nil] body_loc_key
|
149
|
+
# @param [Array<String>, nil] body_loc_args
|
150
|
+
# @param [String, nil] title_loc_key
|
151
|
+
# @param [Array<String>, nil] title_loc_args
|
152
|
+
# @param [String, nil] channel_id
|
153
|
+
# @param [String, nil] ticker
|
154
|
+
# @param [Boolean, nil] sticky
|
155
|
+
# @param [Time, nil] event_time
|
156
|
+
# @param [Boolean, nil] local_only
|
157
|
+
# @param [String, nil] priority
|
158
|
+
# @param [Array<Numeric>, nil] vibrate_timings
|
159
|
+
# @param [Boolean, nil] default_vibrate_timings
|
160
|
+
# @param [Boolean, nil] default_sound
|
161
|
+
# @param [LightSettings, nil] light_settings
|
162
|
+
# @param [Boolean, nil] default_light_settings
|
163
|
+
# @param [String, nil] visibility
|
164
|
+
# @param [Integer, nil] notification_count
|
165
|
+
def initialize(
|
166
|
+
title: nil,
|
167
|
+
body: nil,
|
168
|
+
icon: nil,
|
169
|
+
color: nil,
|
170
|
+
sound: nil,
|
171
|
+
tag: nil,
|
172
|
+
image: nil,
|
173
|
+
click_action: nil,
|
174
|
+
body_loc_key: nil,
|
175
|
+
body_loc_args: nil,
|
176
|
+
title_loc_key: nil,
|
177
|
+
title_loc_args: nil,
|
178
|
+
channel_id: nil,
|
179
|
+
ticker: nil,
|
180
|
+
sticky: nil,
|
181
|
+
event_time: nil,
|
182
|
+
local_only: nil,
|
183
|
+
priority: nil,
|
184
|
+
vibrate_timings: nil,
|
185
|
+
default_vibrate_timings: nil,
|
186
|
+
default_sound: nil,
|
187
|
+
light_settings: nil,
|
188
|
+
default_light_settings: nil,
|
189
|
+
visibility: nil,
|
190
|
+
notification_count: nil
|
191
|
+
)
|
192
|
+
self.title = title
|
193
|
+
self.body = body
|
194
|
+
self.icon = icon
|
195
|
+
self.color = color
|
196
|
+
self.sound = sound
|
197
|
+
self.tag = tag
|
198
|
+
self.image = image
|
199
|
+
self.click_action = click_action
|
200
|
+
self.body_loc_key = body_loc_key
|
201
|
+
self.body_loc_args = body_loc_args
|
202
|
+
self.title_loc_key = title_loc_key
|
203
|
+
self.title_loc_args = title_loc_args
|
204
|
+
self.channel_id = channel_id
|
205
|
+
self.ticker = ticker
|
206
|
+
self.sticky = sticky
|
207
|
+
self.event_time = event_time
|
208
|
+
self.local_only = local_only
|
209
|
+
self.priority = priority
|
210
|
+
self.vibrate_timings = vibrate_timings
|
211
|
+
self.default_vibrate_timings = default_vibrate_timings
|
212
|
+
self.default_sound = default_sound
|
213
|
+
self.light_settings = light_settings
|
214
|
+
self.default_light_settings = default_light_settings
|
215
|
+
self.visibility = visibility
|
216
|
+
self.notification_count = notification_count
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|