Exception: Expo::Push::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/push/client.rb

Overview

rubocop:disable Style/Documentation

Class Method Summary collapse

Class Method Details

.explain(error) ⇒ Object

rubocop:disable Metrics/MethodLength



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/push/client.rb', line 14

def self.explain(error) # rubocop:disable Metrics/MethodLength
  identifier = error.is_a?(String) ? error : error.fetch('details').fetch('error')

  case identifier
  when 'DeviceNotRegistered'
    'The device cannot receive push notifications anymore and you' \
    ' should stop sending messages to the corresponding Expo push token.'
  when 'InvalidCredentials'
    'Your push notification credentials for your standalone app are ' \
    'invalid (ex: you may have revoked them). Run expo build:ios -c ' \
    'to regenerate new push notification credentials for iOS. If you ' \
    'revoke an APN key, all apps that rely on that key will no longer ' \
    'be able to send or receive push notifications until you upload a ' \
    'new key to replace it. Uploading a new APN key will not change ' \
    'your users\' Expo Push Tokens.'
  when 'MessageTooBig'
    'The total notification payload was too large. On Android and iOS ' \
    'the total payload must be at most 4096 bytes.'
  when 'MessageRateExceeded'
    'You are sending messages too frequently to the given device. ' \
    'Implement exponential backoff and slowly retry sending messages.'
  else
    "There is no embedded explanation for #{identifier}. Sorry!"
  end
rescue KeyError
  'There is no identifier given to explain'
end