lib/j7_w1/push_client.rb in j7w1-0.0.1 vs lib/j7_w1/push_client.rb in j7w1-0.0.2
- old
+ new
@@ -2,10 +2,29 @@
module PushClient
def create_sns_client(configuration = J7W1.configuration)
AWS::SNS.new J7W1.configuration.account
end
+ def create_ios_application(name, certs, private_key, options)
+ sandbox = !(options[:sandbox] == false)
+ configuration = options[:sns_configuration] || J7W1.configuration
+
+ private_key = content_from private_key
+ certs = content_from certs
+
+ sns_client = options[:sns_client] || create_sns_client(configuration)
+
+ application_endpoint =
+ sns_client.client.create_platform_application name: name,
+ platform: (sandbox ? 'APNS_SANDBOX' : 'APNS'),
+ attributes: {
+ 'PlatformCredential' => private_key,
+ 'PlatformPrincipal' => certs,
+ }
+ application_endpoint[:platform_application_arn]
+ end
+
def create_device_endpoint(device_identifier, platform, options = {})
custom_user_data = options[:custom_user_data]
sns_configuration = options[:sns_configuration]
sns_client = options[:sns_client]
@@ -75,9 +94,18 @@
def android_payload_for(message_value)
# TODO Android Push Implementation
end
- module_function :create_sns_client, :create_device_endpoint, :push,
- :payload_for, :ios_payload_for, :android_payload_for
+ def content_from(argument)
+ case argument
+ when IO
+ argument.read
+ when String
+ argument
+ end
+ end
+
+ module_function :create_sns_client, :create_ios_application, :create_device_endpoint, :push,
+ :payload_for, :ios_payload_for, :android_payload_for, :content_from
end
end