LoginSignup
1
2

More than 5 years have passed since last update.

[Swift] AmazonSNSでpush通知をする時にCognitoを使わない方法

Last updated at Posted at 2016-11-02

AmazonのドキュメントではcredentialsProviderを作るのにCognitoを使う方法で書かれています。
push通知しか使わない予定なので、無駄な管理と場合によっては料金が発生するのもイヤなので、Cognitoを使わない方法を探しました。
が、Objective-Cでは見つかるものの、Swiftに書き直せばと思ったらメソッドが無かったり・・・
Swiftでの方法を見つけるのが困難だったので載せておきます。

サンプルだとこんな感じになってます。

let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YOUR_IDENTITY_POOL_ID")
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)

AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration

上の部分をアクセスキー、シークレットキーを使う場合は下のようにします。

let aKey = "アクセスキー"
let sKey = "シークレットキー"
let credentialsProvider = AWSStaticCredentialsProvider.init(accessKey: aKey, secretKey: sKey)
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration

ここの部分以外はサンプルと同じ方法で問題ないようです。

※.USEast1 の部分も東京なら「.APNortheast1」なので、お気をつけくださいませ

1
2
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
1
2