Giter Club home page Giter Club logo

Comments (11)

pneves001 avatar pneves001 commented on June 14, 2024 1

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.

avioli avatar avioli commented on June 14, 2024

Are you using the plugin with https:// URIs or custom scheme?

from uni_links.

pneves001 avatar pneves001 commented on June 14, 2024

custom uri scheme. And its on IOS as well.

from uni_links.

avioli avatar avioli commented on June 14, 2024

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.

pneves001 avatar pneves001 commented on June 14, 2024

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.

pneves001 avatar pneves001 commented on June 14, 2024

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.

avioli avatar avioli commented on June 14, 2024

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.

avioli avatar avioli commented on June 14, 2024
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.

avioli avatar avioli commented on June 14, 2024

uni_links ios demo with custom uri scheme

from uni_links.

avioli avatar avioli commented on June 14, 2024

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.

pneves001 avatar pneves001 commented on June 14, 2024

thanks. I'll keep that in mind.

from uni_links.

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.