Skip to content

Instantly share code, notes, and snippets.

View ali-cs's full-sized avatar

Ali ali-cs

  • Pakistan
View GitHub Profile
@ali-cs
ali-cs / MqttAndroidConnection.java
Last active September 10, 2019 13:22
MqttAndroidConnection
String clientId;
CognitoCachingCredentialsProvider credentialsProvider;
AWSIotMqttManager mqttManager;
String clientSecret = "<Your JWT Token>";
public void init() {
clientId = UUID.randomUUID().toString();
@ali-cs
ali-cs / CredentialIdentityAuthenticationProvider.swift
Created September 10, 2019 11:06
CredentialIdentityAuthenticationProvider
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
@ali-cs
ali-cs / MqttConstants.swift
Created September 10, 2019 11:04
MqttConstants
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>