Reputation: 11
I am using singular_flutter_sdk: ^1.0.12 for deep link in my flutter application , in android its working fine but in iOS, when application is already running in background it works but when application is initialised by tapping on the link it only works for first time and when I tap again on link it opens the applications from the background and does not navigate to specific screen .
it should navigate to screen every time when initialising the app using link
import UIKit
import Flutter
import singular_flutter_sdk
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
-> Bool {
GeneratedPluginRegistrant.register(with: self)
if let singularAppDelegate = SingularAppDelegate.shared() {
singularAppDelegate.launchOptions = launchOptions
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let singularAppDelegate = SingularAppDelegate.shared() {
singularAppDelegate.continueUserActivity(userActivity, restorationHandler: nil)
}
return true
}
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let singularAppDelegate = SingularAppDelegate.shared() {
singularAppDelegate.handleOpen(url, options: options)
}
return true
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => MyAppState();
}
class MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
SingularConfig config = SingularConfig(singularApiKey, singularApiSecret);
config.singularLinksHandler = ((SingularLinkParams params) {
String? deeplink = params.deeplink;
String? passthrough = params.passthrough;
bool? isDeferred = params.isDeferred;
// Add your code here to handle the deep link
});
config.waitForTrackingAuthorizationWithTimeoutInterval = 60;
config.skAdNetworkEnabled = true;
config.clipboardAttribution = true;
Singular.event("Launched");
Singular.event("Completed");
Singular.start(config);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: const SplashScreen(),
);
}
}
Upvotes: 0
Views: 1390
Reputation: 59
Did you register your sigular link domain into your iOS project?
Check Xcode > Targets > Signing&Capabilities>Associated Domains
.
The following guides are from the Singular documentation:(https://support.singular.net/hc/en-us/articles/12054824479387--UPDATED-iOS-SDK-Integration-Guide)
Upvotes: 0