18
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWSのSNSからiOSにpush送った

Posted at

メモ。
applicationは事前に登録していた。

require 'aws-sdk'
device_token = 'your device token'
aws_access_key = 'your aws access key'
aws_secret_key = 'your aws secret key'
region = 'your aws region'
application_arn = 'your application arn'

AWS.config(
  access_key_id: aws_access_key,
  secret_access_key: aws_secret_key,
  region: region
)

sns = AWS::SNS.new
client = sns.client
response = client.create_endpoint(
  platform_application_arn: application_arn,
  token: device_token
)
endpoint_arn = response[:endpoint_arn]
client.publish(target_arn: endpoint_arn, message: 'hogehoge')
18
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?