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
String clientId; | |
CognitoCachingCredentialsProvider credentialsProvider; | |
AWSIotMqttManager mqttManager; | |
String clientSecret = "<Your JWT Token>"; | |
public void init() { | |
clientId = UUID.randomUUID().toString(); |
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
class CredentialIdentityAuthenticationProvider : AWSCognitoCredentialsProviderHelper { | |
override func token() -> AWSTask<NSString> { | |
//Write code to call your backend: | |
//pass username/password to backend or some sort of token to authenticate user, if successful, | |
//from backend call getOpenIdTokenForDeveloperIdentity with logins map containing "your.provider.name":"enduser.username" | |
//return the identity id and token to client | |
//You can use AWSTaskCompletionSource to do this asynchronously | |
// Set the identity id and return the token |
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
struct MqttConstants { | |
static let endPoint = "wss://a1pvqgswwsbwvy-ats.iot.eu-west-1.amazonaws.com/mqtt" // "wss:<IotEndpointATS>/mqtt | |
static let IdentityPool = "eu-west-1:9b8ca290-c620-452c-120c-77c6c442v6fd" // <IdentityPool> | |
static let UserPool = "<eu-west-1_bHTWQN1lI>" // <UserPool> | |
static let kMQTTMKey = "MQTTManager" // change to any key as your like :) | |
static let mqttCognitoKey = "cognito-idp.\(awsRegionString).amazonaws.com/\(UserPool)" // "cognito-idp.<REGION>.amazonaws.com/<UserPool> |