I have an issue with a flutter implementation on Android. On iOS it works fine.
Here is my AndroidManifest.xml:
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp"/>
</intent-filter>
I defined the SpotifyClient like that:
class SpotifyOAuth2Client extends OAuth2Client {
SpotifyOAuth2Client({required String redirectUri, required String customUriScheme}) :
super(
authorizeUrl: 'https://accounts.spotify.com/authorize',
tokenUrl: 'https://accounts.spotify.com/api/token',
redirectUri: redirectUri,
customUriScheme: customUriScheme) {
this.accessTokenRequestHeaders = {'Accept': 'application/json'};
}
}
And here is where I try to call the client:
OAuth2Client client = SpotifyOAuth2Client(
redirectUri: 'com.mycomp.myapp://callback',
customUriScheme: 'com.mycomp.myapp');
var authResp = await client.requestAuthorization(
clientId: 'huhuhuhuhuhuhuhuhu',
customParams: {'show_dialog': 'true'},
scopes: ['user-read-private', 'user-read-playback-state', 'user-modify-playback-state', 'user-read-currently-playing', 'user-read-email']);
print(authResp.code);
The app is correctly triggering the authorization to Spotify. I get to log in and accept on the web browser.
Then I get redirected to myApp but nothing happens. The print(authResp.code) (and of course everything following) above never fires.
Again, on iOS I have no issue.
I have been trying many thing but with no success. Any help would be much appreciated!
After many trials, I have been able to fix the issue.
Hope it can help somebody else.
Adding the following activity (and not only intent-filter in an existing activity) made the trick:
<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp" android:host="callback" />
</intent-filter>
</activity>
hi can you share the code? my code no works when try to add another activity
<activity
android:name="io.flutter.embedding.android.SplashScreenDrawable">
<intent-filter android:label="flutter_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.mycomp.myapp" android:host="callback" />
</intent-filter>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
</activity>
Related
This is what I got in my Manifest:
<activity
android:name=".activities.VidyoSampleActivity"
android:label="#string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_hjyeOhAByhF1x452yXtuEjdpCzhMiEAB" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="c13e89c059c32c08041932f2d48b4e5bf1054b4a" />
I am using this version: compile 'io.branch.sdk.android:library:2.+'
And I do in my Application class the initialization.
This is the url scheme I have set on my dashboard.branch.io: facetalk://
But when I try this link:
facetalk://facetalk.vidyo-nl.com/mobile.html?key=saETMuvxjeW2akgzbyt46Xffio&guestname=Test123&secure=yes
It does nothing.
Why is that?
I even created the code for branch from the Fabric AndroidStudio plugin. and it still doesn't work. What am I doing wrong?
Let me know if more info is needed
PS: If I remove from the intent filter this:
android:host="open"
It will work. But I don't think it goes via branch like that. cause it doesn't enter this:
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchReferralInitListener() {
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
Log.i("BranchConfigTest", "deep link data: " + referringParams.toString());
}
}
}, this.getIntent().getData(), this);
After adding some logs. I found out that this is getting logged, when the app starts the first time:
11-16 12:18:45.237: I/BranchConfigTest(25065): deep link data: {"+is_first_session":false,"+clicked_branch_link":true,"room":"DpoxihjuKKKE24FAP2ByTILdZsg","guestname":"John","secure":"true","$marketing_title":"Join Conference","$one_time_use":false,"~creation_source":1,"~feature":"marketing","~id":"325753563785928408","~marketing":true,"+click_timestamp":1479295095,"+match_guaranteed":true,"~referring_link":"https:\/\/facetalk.app.link\/join?room=DpoxihjuKKKE24FAP2ByTILdZsg&guestname=John&secure=true"}
I don't understand how this is being shown? Cause I just launch the app, I did not press any link.
Also when I press on a link I created, this does not get called anymore
Alex from Branch.io here: you need to create a Branch link and test with that URL. Directly entering the deep link path with the URI scheme is not the correct implementation and (as you discovered) will not work.
The Branch.io Integration shows that I need to add the intent as this:
<intent-filter>
<data android:scheme="facetalk" android:host="open"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
But that did not work for me for branch 2.x.
This was the way I was able to add the intent:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="facetalk.app.link" />
</intent-filter>
I'm trying to open my app from Chrome but it doesn't work for me..
Here's the official (very limited) documentation:
Android Intents with Chrome
I've found a bunch of similar questions but none of the solutions seem to work for me - also, the answers are a bit fragmented so I'm looking for the complete answer with example. I'd be happy to post my full solution as soon as we found it :)
Launching an Android Application from the Browser
Open Android app from URL using intent-filter not working
Here's what I got now:
AndroidManifest.xml:
<activity android:name=".ActMain" >
<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:scheme="http" />
<data android:scheme="https" />
<data android:scheme="sharedr" />
<data android:host="pocketr.rejh.nl" />
<data android:pathPattern="/.*" />
</intent-filter>
</activity>
Javascript (it builds the intent link when user clicks on an element):
var url = "http://icerrr.rejh.nl/"
var title = "Example"
var intenturl = "intent://sharedr/#Intent;"
+ "package=com.rejh.sharedr;"
+ "S.action=share;"
+ "S.type=url;"
+ "S.title="+ app.helpers.encodeURIComponent(title) +";"
+ "S.url="+ app.helpers.encodeURIComponent(url) +";"
+ "end";
alert(intenturl); // for debugging
try {
window.location.href=intenturl;
} catch(e) { alert(JSON.stringify(e)); }
I get the following 'link' from this function:
intent://sharedr/#Intent;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end
Human-readable:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
So this works as in: it opens the Play Store and shows "Item not found" and a Refresh button. So it opens an activity but not the right one..
The website I'm trying to fire this from is http://pocketr.rejh.nl
Help?
The full answer
As pointed out by Mattia below (and I just figured this out myself but found the answer waiting for me... :P)
First of all: I forgot to include the 'scheme=sharedr' in my intent link:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
Should be (notice the 2nd line):
intent://sharedr/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
Then, in the android manifest:
<activity android:name=".ActMain" >
<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:scheme="sharedr" android:host="sharedr" android:path="/"/>
</intent-filter>
</activity>
Where 'android:scheme="sharedr"' is the 'scheme=sharedr' part and 'android:host="sharedr"' corresponds to 'intent://sharedr/'
Thanks!
You specify sharedr as host but the host configured in your AndroidManifest.xml is pocketr.rejh.nl. Also you didn't specify the scheme.
The URL fixed is this:
intent://pocketr.rejh.nl/#Intent;scheme=sharedr;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end
Human-readable:
intent://pocketr.rejh.nl/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
I have a problem implementing Oauth in Android using signpost library. Everything is fine except the final part when it should return to the application itself after granting access.
Below is my activity callback declaration in manifest:
<activity android:name="ro.locationsApp.android.login.LoginScreenActivity"
android:screenOrientation="portrait"
android:launchMode="singleTask">
<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:scheme="http" android:host="myCallbackHost"/>
</intent-filter>
</activity>
And I pass the Callback URL from code like this:
new OAuthHelper("mySite", "secret",
"https://www.googleapis.com/auth/userinfo.profile", "http://myCallbackHost");
Where myCallbackHost it's a real and functional link(it's also used for callback after a web site authentication - now I want mobile too).
The problem is that my android app is not called after this. I also tried
<data android:scheme="customScheme"/>
and
new OAuthHelper("mySite", "secret",
"https://www.googleapis.com/auth/userinfo.profile", "customScheme:///");
but without success.
Thanks,
Alex.
Changing http with something else works.
Here is how my manifest looks now:
<activity android:name="ro.locationsApp.android.login.LoginScreenActivity"
android:screenOrientation="portrait"
android:launchMode="singleTask">
<intent-filter>
<category android:name="android.intent.category.LUNCHER" />
</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:scheme="alex" android:host="me"/>
</intent-filter>
</activity>
and code:
new OAuthHelper("mySite", "secret",
"https://www.googleapis.com/auth/userinfo.profile", "alex://me");
works like a charm.
I want from the android browser be able to launch my application if it's installed, or launch my website in the other case.
So in order to make it work, I put :
<activity android:name=".MMLogin" android:label="MeetMe" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="http" android:host="meet-me.com" android:path="/signin" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
in the Manifest, and I created a dummy link to test; and it's not working.
I've tried with and without: BROWSABLE and DEFAULT
I've tried with meetme://datas and change the scheme; nothing worked.
I used threads on stackoverflow like :
Launch custom android application from android browser
What am I doing wrong, or is there a special thing to do to make it work ?
My application suppports from API 7.
Cheers
I used :
Intent Filter to Launch My Activity when custom URI is clicked, I think what was missing is this block :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/myapp" />
</intent-filter>
Im trying to create my own url scheme so my android app can get called via an URL but for now I dont have a success.
Im trying to have this url to work : cedemo://com.cedemo.scan?X=toto
Here is part of my manifest file :
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.GALLERY" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
Does anyone can help telling me what is wrong ?
Also, if someone find what is wrong, can someone tell me how I read the "X" variable from inside the android code from my app ?
Update:
Update: I did the modification of the action (as advised in one of the answers) and it's worked fine. The thing is that I still cannot get the url variable value. Here is the code I tried.
final Intent intent = getIntent();
final String myScheme=intent.getScheme();
final Bundle myBundle=intent.getExtras();
final boolean inContestKey;
if (myBundle != null) {
inContestKey=myBundle.containsKey("inContest");
}
final Uri myURI=intent.getData();
final String value;
if (myURI != null) {
value = myURI.getQueryParameter("inContest");
}
But I receiving null from all the functions… what else can i do?
May be I should explain better the context of my software:
My software is started
My software launch then the browser
the user click a link in the browser and the browser go to the url scheme, back to the software with a variable "X" (for example)
the software should read the variable "X"
But in my case : myScheme, myBundle, myURI are set to null.
Any ideas ?
Update:
I found the answer is that you have to be in the main activity to do that.
I think the problem is with the Action you defined.
There is a "android.intent.action.VIEW" which is what I think you want.
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<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:scheme="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
Try that and I bet will resolve correctly. I only made this assumption because you included the browsable category which is usually used by the Browser, which does not know of any of your custom actions. If you do want the GALLERY action as you have implied then just create 2 filters
<activity android:name=".Gallery1" android:label="#string/app_name" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.GALLERY" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="cedemo" android:host="com.cedemo.scan" />
</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:scheme="cedemo" android:host="com.cedemo.scan" />
</intent-filter>
</activity>
So within the contents of your activity you can do something like:
// Value should be "toto" as in your example
String value = getData().getQueryParameter("X");
What finally fixed things for me was changing the order of the XML elements. Specifically, swapping the data and action rows so data is before action made it start working.
<intent-filter>
<data android:scheme="myappname" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
And for completeness, my link in the html is "myappname://noop".
One more thing, i would like to throw light. Initially it was not working for me because i was using Main/Launcher tags before View/Default/Browsable/data.
Once i changed the order it started working fine.
i.e Initially not working code
<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:scheme="myapp" />
</intent-filter>
correct code order
<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:scheme="myapp" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
and way to test for android is very simple.
Make any html file insert
test to launch myapp <br /><br />
just open this html file and click on test to .... :-)