GithubHelp home page GithubHelp logo

Comments (7)

romeoflute avatar romeoflute commented on August 15, 2024 4

Oh man, this is a year ago. Where did the pool go?

from aws-mobile-appsync-sdk-ios.

rohandubal avatar rohandubal commented on August 15, 2024

Hello @alionthego

Thanks for reporting this. I will put together example and update this thead.

Thanks,
Rohan

from aws-mobile-appsync-sdk-ios.

rubyrose-aws avatar rubyrose-aws commented on August 15, 2024

@alionthego Sorry for the delayed response. Here is the snippet you need:

import AWSAppSync

class MyCognitoUserPoolsAuthProvider: AWSCognitoUserPoolsAuthProvider {

    func getLatestAuthToken() -> String {
        var token: String? = nil
        pool.currentUser()?.getSession().continueOnSuccessWith(block: { (task) -> Any? in
            token = task.result!.idToken!.tokenString
            return nil
        }).waitUntilFinished()
        return token!
    }
}
// You can choose your database location, accessible by the SDK
let databaseURL = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent(database_name)

do {
  // Initialize the AWS AppSync configuration
   let appSyncConfig = try AWSAppSyncClientConfiguration(url: "endpoint-url",
                                                         serviceRegion: "region",
                                                         userPoolsAuthProvider: MyCognitoUserPoolsAuthProvider(),
                                                         databaseURL: databaseURL)

    // Initialize the AWS AppSync client
    appSyncClient = try AWSAppSyncClient(appSyncConfig: appSyncConfig)
} catch {
    print("Error initializing appsync client. \(error)")
}

from aws-mobile-appsync-sdk-ios.

rohandubal avatar rohandubal commented on August 15, 2024

This feature has been added with SDK version 2.6.20+

from aws-mobile-appsync-sdk-ios.

kadishmal avatar kadishmal commented on August 15, 2024

@alionthego Sorry for the delayed response. Here is the snippet you need:

import AWSAppSync

class MyCognitoUserPoolsAuthProvider: AWSCognitoUserPoolsAuthProvider {

    func getLatestAuthToken() -> String {
        var token: String? = nil
        pool.currentUser()?.getSession().continueOnSuccessWith(block: { (task) -> Any? in
            token = task.result!.idToken!.tokenString
            return nil
        }).waitUntilFinished()
        return token!
    }
}

Where is pool coming from? It's undefined.

Using AWSAuthCore (2.6.18)
Using AWSAuthUI (2.6.18)
Using AWSCognitoIdentityProvider (2.6.18)
Using AWSCognitoIdentityProviderASF (1.0.1)
Using AWSCore (2.6.18)
Using AWSMobileClient (2.6.18)
PODS:
  - AWSAppSync (2.6.23):
    - AWSCore (~> 2.6.6)
    - ReachabilitySwift (~> 4.0.0)
    - SQLite.swift (= 0.11.4)
  - AWSAuthCore (2.6.18):
    - AWSCore (= 2.6.18)
  - AWSAuthUI (2.6.18):
    - AWSAuthCore (= 2.6.18)
    - AWSCore (= 2.6.18)
  - AWSCognitoIdentityProvider (2.6.18):
    - AWSCognitoIdentityProviderASF (= 1.0.1)
    - AWSCore (= 2.6.18)
  - AWSCognitoIdentityProviderASF (1.0.1)
  - AWSCore (2.6.18)
  - AWSMobileClient (2.6.18):
    - AWSAuthCore (= 2.6.18)
  - AWSUserPoolsSignIn (2.6.18):
    - AWSAuthCore (= 2.6.18)
    - AWSCognitoIdentityProvider (= 2.6.18)
  - ReachabilitySwift (4.0.0)
  - SQLite.swift (0.11.4):
    - SQLite.swift/standard (= 0.11.4)
  - SQLite.swift/standard (0.11.4)

from aws-mobile-appsync-sdk-ios.

kadishmal avatar kadishmal commented on August 15, 2024

It worked after updating all dependencies.

from aws-mobile-appsync-sdk-ios.

linkrahul avatar linkrahul commented on August 15, 2024

@kadishmal How did you solve the pool undefined issue ?

from aws-mobile-appsync-sdk-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.