diff --git a/internalsdk/session_model.go b/internalsdk/session_model.go index 5dd29acaa..6c26a18a3 100644 --- a/internalsdk/session_model.go +++ b/internalsdk/session_model.go @@ -19,6 +19,7 @@ import ( "github.com/getlantern/lantern-client/internalsdk/auth" "github.com/getlantern/lantern-client/internalsdk/common" "github.com/getlantern/lantern-client/internalsdk/ios" + iosGeoLookup "github.com/getlantern/lantern-client/internalsdk/ios/geolookup" "github.com/getlantern/lantern-client/internalsdk/pro" "github.com/getlantern/lantern-client/internalsdk/protos" "github.com/getlantern/pathdb" @@ -186,13 +187,29 @@ func NewSessionModel(mdb minisql.DB, opts *SessionModelOpts) (*SessionModel, err m.baseModel.doInvokeMethod = m.doInvokeMethod if opts.Platform == "ios" { - go m.setupIosConfigure(opts.ConfigPath, int(userID), token, deviceID) + go m.iosInit(opts.ConfigPath, int(userID), token, deviceID) } log.Debugf("SessionModel initialized") go m.initSessionModel(context.Background(), opts) return m, nil } +// this method initializes the ios configuration for the session model +// also this method check for geoLookup +func (m *SessionModel) iosInit(configPath string, userId int, token string, deviceId string) error { + go m.setupIosConfigure(configPath, userId, token, deviceId) + // go iosGeoLookup.Refresh() + go func() { + if <-iosGeoLookup.OnRefresh() { + country := iosGeoLookup.GetCountry(5 * time.Second) + //get the country for the user + log.Debugf("Getting country for user %v", country) + m.SetCountry(country) + } + }() + return nil +} + // setupIosConfigure sets up the iOS configuration for the session model. // It continuously checks if the global configuration is available and retries every second if not. func (m *SessionModel) setupIosConfigure(configPath string, userId int, token string, deviceId string) { @@ -898,7 +915,6 @@ func (m *SessionModel) GetToken() (string, error) { } func (m *SessionModel) SetCountry(country string) error { - //Find better way to do it return pathdb.Mutate(m.db, func(tx pathdb.TX) error { return pathdb.Put(tx, pathGeoCountryCode, country, "") }) @@ -1552,6 +1568,7 @@ func checkAdsEnabled(session *SessionModel) error { return err } if isPro { + log.Debug("User is pro ads should be disabled") return pathdb.Mutate(session.db, func(tx pathdb.TX) error { return pathdb.Put[string](tx, pathShowAds, "", "") }) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 727705d2b..8d10807d5 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -2,6 +2,7 @@ import Flutter import Internalsdk import SQLite import UIKit +import app_links //know Issue //  CFPrefsPlistSource<0x28281e580> (Domain: group.getlantern.lantern, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, @@ -34,6 +35,11 @@ import UIKit print(exception.reason) print(exception.callStackSymbols) } + if let url = AppLinks.shared.getLink(launchOptions: launchOptions) { + // We have a link, propagate it to your Flutter app or not + AppLinks.shared.handleLink(url: url) + return true + } return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 65a133f5b..277025344 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -19,13 +19,17 @@ CFBundlePackageType APPL CFBundleShortVersionString - 8.0.2 + 8.0.3 CFBundleSignature ???? CFBundleVersion - 50 + 51 + LSApplicationCategoryType + CURRENT_SCHEME_NAME $(CURRENT_SCHEME_NAME) + FlutterDeepLinkingEnabled + GADApplicationIdentifier ca-app-pub-2685698271254859~9283700921 LSRequiresIPhoneOS diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index 35d1a2c75..1069c91f2 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -4,6 +4,11 @@ aps-environment development + com.apple.developer.associated-domains + + applinks:lantern.io + webcredentials:lantern.io + com.apple.developer.networking.networkextension packet-tunnel-provider diff --git a/pubspec.lock b/pubspec.lock index 27536783a..b3261af03 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,10 +42,10 @@ packages: dependency: "direct main" description: name: app_links - sha256: ad1a6d598e7e39b46a34f746f9a8b011ee147e4c275d407fa457e7a62f84dd99 + sha256: "433df2e61b10519407475d7f69e470789d23d593f28224c38ba1068597be7950" url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" app_links_linux: dependency: transitive description: @@ -880,10 +880,10 @@ packages: dependency: "direct main" description: name: get_it - sha256: c49895c1ecb0ee2a0ec568d39de882e2c299ba26355aa6744ab1001f98cebd15 + sha256: f126a3e286b7f5b578bf436d5592968706c4c1de28a228b870ce375d9f743103 url: "https://pub.dev" source: hosted - version: "8.0.2" + version: "8.0.3" gettext_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d40bfd20b..6674b3404 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -130,9 +130,9 @@ dependencies: # Generate bindings to native libraries ffi: ^2.1.3 # Deeplink handling - app_links: ^6.3.2 + app_links: ^6.3.3 # Service Locator - get_it: ^8.0.2 + get_it: ^8.0.3 #Loading animated_loading_border: ^0.0.2 shimmer: ^3.0.0