Created
June 10, 2024 00:36
-
-
Save codelynx/7458a592aaf108e9f518f726d7645d8d to your computer and use it in GitHub Desktop.
Register Apple's push notification device token to Amazon AWS SNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Using AWS-SDK-SWIFT to register push notification deveice token | |
https://github.com/awslabs/aws-sdk-swift | |
*/ | |
// import some others | |
import AWSSNS | |
func createPlatformEndpoint(token: String, region: String, accessKey: String, secret: String, platformApplicationArn: String) async { | |
do { | |
let credentialsResolver = try StaticAWSCredentialIdentityResolver( | |
.init(accessKey: accessKey, secret: secret) | |
) | |
let config = try await SNSClient.SNSClientConfiguration( | |
awsCredentialIdentityResolver: credentialsResolver, region: region | |
) | |
let snsClient = SNSClient(config: config) | |
let input = CreatePlatformEndpointInput(attributes: [:], customUserData: nil, platformApplicationArn: platformApplicationArn, token: token) | |
let endpointArn = try await snsClient.createPlatformEndpoint(input: input) | |
print("endpointArn=", endpointArn) | |
} | |
catch { | |
print("\(error)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment