Comments (11)
Thanks for the help. I think I just found the problem I was having. It was an issue with asynchronous function calls not executing in time. I've fixed the problem. it was just hard for me to find the issue. Thank you. Sorry for making you take the time for this issue.
from uni_links.
Are you using the plugin with https:// URIs or custom scheme?
from uni_links.
custom uri scheme. And its on IOS as well.
from uni_links.
Custom URI schemes are the easiest. They can be easily tested with little effort. They also work fine on the iOS Simulator.
Follow the guide in the README.md line by line.
Here's the checklist:
- Declare your Custom URI scheme in
ios/Runner/Info.plist
; - Add dart code for Initial Link (and on-change event);
- Run app and quit/detach;
- Ensure the app has terminated on the simulator/device by checking the recently used apps (aka app switcher). If not - flick it up to terminate it or tap-and-hold then terminate it via the X;
- Run any of the testing commands from the README.md.
NOTE: The simulator/device may ask you if you want to open the link in the app.
The most common problem is that you cannot get the initial link, unless the app was terminated and then started, because of the Custom URI Link.
If you still have problems - clone the repo and open up the example project - it is setup for Custom URI scheme. Run the example app, terminate it and run any of the testing commands.
from uni_links.
The plugin works once the app is loaded. If I run the app and then open up the link from a browser it works. It doesn't work if the app is not loaded and we load the app by clicking on the link. Then it just loads the app but doesn't return the initial link or execute the on change event.
I'm using an Ipod touch for my device, not the simulator. The initial Link code returns null.
from uni_links.
I've tried what you've mentioned here as what I should do. Its not working. It won't provide the URI on launch. It works if the app is already loaded. But not on launch.
from uni_links.
I just:
- created a brand new Flutter project,
- added uni_links dep,
- defined the scheme,
- added relevant code to main.dart,
- installed the app in the simulator (don't have an iPod Touch),
- terminated it,
- opened an html page that has the link with the scheme in the simulator,
- clicked the link,
- iOS asked if I want to open the app that can handle the link and I confirmed,
- the UI of the app showed that the initial link is set to the right thing.
I'm not sure where you go wrong.
from uni_links.
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index cda4b49..d5327f0 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -41,5 +41,18 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ <key>CFBundleURLName</key>
+ <string>test.unilinks</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>unilinks0000001</string>
+ </array>
+ </dict>
+ </array>
</dict>
</plist>
diff --git a/lib/main.dart b/lib/main.dart
index 94b23e9..7b72f9a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,4 +1,9 @@
+import 'dart:async';
+import 'dart:io';
+
import 'package:flutter/material.dart';
+import 'package:uni_links/uni_links.dart';
+import 'package:flutter/services.dart' show PlatformException;
void main() => runApp(new MyApp());
@@ -44,6 +49,28 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
+ String _link;
+
+ @override
+ void initState() {
+ super.initState();
+ initUniLinks();
+ }
+
+ Future<Null> initUniLinks() async {
+ // Platform messages may fail, so we use a try/catch PlatformException.
+ try {
+ String initialLink = await getInitialLink();
+ // Parse the link and warn the user, if it is not correct,
+ // but keep in mind it could be `null`.
+ setState(() {
+ _link = initialLink;
+ });
+ } on PlatformException {
+ // Handle exception by warning the user their action did not succeed
+ // return?
+ }
+ }
void _incrementCounter() {
setState(() {
@@ -89,21 +116,10 @@ class _MyHomePageState extends State<MyHomePage> {
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
- new Text(
- 'You have pushed the button this many times:',
- ),
- new Text(
- '$_counter',
- style: Theme.of(context).textTheme.display1,
- ),
+ new Text(_link ?? "no initial link"),
],
),
- ),
- floatingActionButton: new FloatingActionButton(
- onPressed: _incrementCounter,
- tooltip: 'Increment',
- child: new Icon(Icons.add),
- ), // This trailing comma makes auto-formatting nicer for build methods.
+ )
);
}
}
diff --git a/pubspec.lock b/pubspec.lock
index 498026c..dc4053d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -338,6 +338,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
+ uni_links:
+ dependency: "direct main"
+ description:
+ name: uni_links
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.3"
utf:
dependency: transitive
description:
@@ -382,3 +389,4 @@ packages:
version: "2.1.15"
sdks:
dart: ">=2.0.0-dev.68.0 <3.0.0"
+ flutter: ">=0.1.4 <2.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 44fad74..9cd147a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -20,6 +20,8 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
+ uni_links: ^0.1.3
+
dev_dependencies:
flutter_test:
sdk: flutter
from uni_links.
from uni_links.
Just fyi - initial link should be ALWAYS the same if the app was started with one, no matter how late you request it.
from uni_links.
thanks. I'll keep that in mind.
from uni_links.
Related Issues (20)
- 第一次玩这个
- Enable/Disable the deep links at code level
- Doesn't work with Firebase dynamic Links. HOT 2
- Android app link not working in android 12 always opening in browser HOT 4
- applink not working on ios HOT 3
- IOS universal link does not work in chrome. HOT 3
- No more maintained? HOT 2
- How to get queryParams in Deeplink? HOT 1
- Build fail with AGP 8.0 HOT 2
- URI Link with '&' in the link won't recognized as uni link HOT 1
- Does not trigger with a subdomain on iOS HOT 1
- Android : Can't open app with deeplink in chrome. HOT 6
- Unable to get deep link when user first time installed the app via GooglePlay HOT 3
- Test deep link during development by clicking on something HOT 1
- Namespace not specified. Specify a namespace in the module's build file HOT 4
- Not working with Flutter add-to-app in iOS HOT 1
- Can't get it to work on Android with subdomain HOT 6
- [Android] When i use the universal link to open Android, avoid reload the full app.
- getInitialUri doesn't work for iOS (16.6.1) HOT 1
- uni_link worked for me on Android but I couldn't get it to work on IOS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uni_links.