Problems wit redirect URI Flutter - flutter

I tried, to authenticate my App at Spotify, via FlutterWebAuth2, but I always, get a "Illegal redirect Uri" Error.
My authentication function
try {
var redirectURI = 'beatrunner:/';
final result = await FlutterWebAuth2.authenticate(
url:
"https://accounts.spotify.com/authorize?client_id=xxxx&redirect_uri= $redirectURI&scope=user-read-currently-playing&response_type=token&state=123",
callbackUrlScheme: "beatrunner",
);
} catch (e) {
print(e);
}
}
My Android Manifest file
<activity android:name="com.linusu.flutter_web_auth2.CallbackActivity" android:exported="true">
<intent-filter android:label="flutter_web_auth2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="beatrunner" />
</intent-filter>
</activity>
I tried to solve my Problem using this articlehttps://stackoverflow.com/questions/58244209/flutter-oauth2-problems-with-redirect-uri, but I still get a error message.

Related

Im trying to get link after deep linking rotate

im opening app from link. but i cant listen my link after opened app. i need to get a token from link.
AndroidManifest.xml:
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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="https"
android:host="myappname.page.link" />
</intent-filter>
and my listener uni_links like that:
getLinksStream().listen((link) async {
print("urigirdi");
try {
var _latestUri;
if (link != null) _latestUri = Uri.parse(link);
setState(() {
sourceLink = link!.split("/")[3];
print("link");
linkToken = sourceLink.split("?")[2];
linkPath = sourceLink.split("?")[0];
print(linkPath);
print(linkToken);
});
} on FormatException {
print("--- A link got here but was invalid");
}
});
i need some help. can anybody help me ? thanks for everything...

Set default browser flutter

I am making a mobile browser app. When you download a browser from the play market, then a notification pops up "Which browser do you want to use by default?". How to do it?
Update:
I added this filter to AndroidManifest.xml file. And now, when you click on a link in any application, it asks through which browser to open the link, but now how to intercept this link to send it to the webview? As here
<intent-filter>
<action android:name="android.speech.action.VOICE_SEARCH_RESULTS" />
<category android:name="android.intent.category.DEFAULT" />
</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="about" />
<data android:scheme="javascript" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="inline" />
<data android:mimeType="text/html" />
<data android:mimeType="text/plain" />
<data android:mimeType="application/xhtml+xml" />
<data android:mimeType="application/vnd.wap.xhtml+xml" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.WEB_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MEDIA_SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
You can use this package receive_sharing_intent
example code:
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
class MyApp extends StatefulWidget {
const MyApp({super.key});
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late StreamSubscription _intentDataStreamSubscription;
String? _sharedText;
#override
void initState() {
super.initState();
// For sharing or opening urls/text coming from outside the app while the app is in the memory
_intentDataStreamSubscription =
ReceiveSharingIntent.getTextStream().listen((String value) {
setState(() {
_sharedText = value;
print("Shared: $_sharedText");
});
}, onError: (err) {
print("getLinkStream error: $err");
});
// For sharing or opening urls/text coming from outside the app while the app is closed
ReceiveSharingIntent.getInitialText().then((String? value) {
setState(() {
_sharedText = value;
print("Shared: $_sharedText");
});
});
}
#override
void dispose() {
_intentDataStreamSubscription.cancel();
super.dispose();
}
#override
Widget build(BuildContext context) {
const textStyleBold = TextStyle(fontWeight: FontWeight.bold);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
const Text("Shared urls/text:", style: textStyleBold),
Text(_sharedText ?? "")
],
),
),
),
);
}
}

share list of Images from gallery and any type of files from outside our application:

I'm trying to share a list of images from the gallery into my app to use it recycler view
or any thing else
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*"/>
</intent-filter>
</activity>
that works:-
1-specify these lines on the manifest
<activity
android:icon="#mipmap/ic_launcher"
android:name=".MainActivity"
>
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="*/*"/>
<data android:mimeType="image/jpeg" />
<data android:mimeType="image/png" />
<data android:mimeType="image/jpg" />
</intent-filter>
</activity>
2-Second get the action that opened your intent and check if its the one we registered for the activity and then the data is received as ArrayList of Uri
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
Bundle extras = intent.getExtras();
if (extras.containsKey(Intent.EXTRA_STREAM)) {
ArrayList<Uri> urisArrayList = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
urisArrayList.forEach(i-> Log.d(TAG, "onCreate: "+i.toString()));
}
}}

how to open different activities when receiving notification from parse

I have different categories in my app such as news,weather,sports and technology,I use parse to receive notification ,but i want the notification to be customized in which once a notification regarding news is received it should open news activity,if notification regarding technology is received it should open technology activity.
I don't want custom push receiver,i tried lots of examples but i can't get it.any ideas thanks in advance
First you need to create a custom class that extends ParsePushBroadcastReceiver.
and in that class you Override onPushOpen method:
public class ParsePushCustomReceiver extends ParsePushBroadcastReceiver {
protected static String pushTitle="";
#Override
protected void onPushOpen(Context context, Intent intent) {
super.onPushOpen(context, intent);
pushTitle="";
try {
Bundle extras = intent.getExtras();
if (extras != null) {
String jsonData = extras.getString("com.parse.Data");
JSONObject json;
json = new JSONObject(jsonData);
pushTitle = json.getString("title");
String pushContent = json.getString("alert");
//intent to your activity
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Now when you have the title and the content of the push you can direct to the activity that you want to go...
You need to define your custom ParsePushBroadcastReceiver as reciever in AndroidManifest.xml:
<!-- Parse PushService-->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.appname.appname.ParsePushCustomReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.appname.appname" />
</intent-filter>
</receiver>

Revmob Unity : Banner ads not clickable

I am developing a game which required to show Revmob Banner ads.
I can successfully show banner ads, but can't not click on it. It's media id is into testing mode.
My code for it is below.
private RevMob rev mob;
void Awake() {
revmob = RevMob.Start(REVMOB_APP_IDS, "RevMob");
}
void Start() {
revmob.CreateBanner(RevMob.Position.BOTTOM);
revmob.ShowBanner(RevMob.Position.BOTTOM);
}
Please help me.
Try adding the following line in the AndroidManifest.xml file within the activity tags for UnityPlayerNativeActivity
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
Example
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false" android:largeHeap="true">
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>