Skip to content

Make sure your phone has Internet connection. #216

@RethinavelPillai

Description

@RethinavelPillai

I had followed the same code mentioned here. But Whenever I try to connect, I am getting this error always. Logs didn't help. What could be the issue?

WhatsApp Image 2021-01-06 at 6 05 45 PM

`
class MainActivity : AppCompatActivity() {
lateinit var connectButton: ConnectButton

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    connectButton = findViewById(R.id.connect_button)
    val provider: CredentialsProvider = object : CredentialsProvider {
        override fun getOAuthCode(): String {
            return "user_oauth_code"
        }

        override fun getUserToken(): String {
            return "ifttt_user_token"
        }
    }
    val uriResult = Uri.parse("smitchsecurity://connect_callback")
    val configuration = ConnectButton.Configuration.newBuilder(
        "androidvelu@gmail.com",
        uriResult
    )
        .withConnectionId("MvTEYeDG")
        .withCredentialProvider(provider)
        .build()
    connectButton.setup(configuration)

    connectButton.addButtonStateChangeListener(object : ButtonStateChangeListener {
        override fun onStateChanged(
            currentState: ConnectButtonState,
            previousState: ConnectButtonState,
            connection: Connection
        ) {
            Log.e("currentState ", "currentState  $currentState")
            Log.e("previousState ", "previousState  $previousState")
            Log.e("connection ", "connection  $connection")
        }

        override fun onError(errorResponse: ErrorResponse) {
            Log.e("The error Response ", "Error Response  $errorResponse")
        }
    })
}


override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    Log.e("onNewIntent", " ${intent}")
    val connectResult = ConnectResult.fromIntent(intent)
    connectButton.setConnectResult(connectResult)
}

}

`

and here is the manifest file

`

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.IFTTTPrimary">

    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTask">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="smitchsecurity://connect_callback"
                android:scheme="smitchsecurity://connect_callback" />

        </intent-filter>

    </activity>
</application>
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions