Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
c21e87c1
Commit
c21e87c1
authored
May 20, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-74: AppsFlyer deep links handling.
parent
c6a643bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
14 deletions
+48
-14
1Weather/AppDelegate.swift
+39
-10
1Weather/Coordinators/DeeplinksRouter.swift
+9
-4
No files found.
1Weather/AppDelegate.swift
View file @
c21e87c1
...
@@ -38,6 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -38,6 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
appsFlyer
.
appsFlyerDevKey
=
kAppsFlyerId
appsFlyer
.
appsFlyerDevKey
=
kAppsFlyerId
appsFlyer
.
appleAppID
=
kAppsFlyerAppId
appsFlyer
.
appleAppID
=
kAppsFlyerAppId
appsFlyer
.
delegate
=
self
appsFlyer
.
delegate
=
self
appsFlyer
.
deepLinkDelegate
=
self
#if DEBUG
#if DEBUG
appsFlyer
.
isDebug
=
true
appsFlyer
.
isDebug
=
true
#else
#else
...
@@ -53,7 +54,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -53,7 +54,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
if
let
userQualifiedDate
=
Settings
.
shared
.
userQualifiedDate
{
if
let
userQualifiedDate
=
Settings
.
shared
.
userQualifiedDate
{
let
timeSinceQualified
=
Date
()
.
timeIntervalSince
(
userQualifiedDate
)
let
timeSinceQualified
=
Date
()
.
timeIntervalSince
(
userQualifiedDate
)
let
day
=
TimeInterval
(
3600
*
24
)
let
day
=
TimeInterval
(
3600
*
24
)
if
timeSinceQualified
>=
3
*
day
&&
timeSinceQualified
<
6
*
day
{
if
timeSinceQualified
>=
3
*
day
&&
timeSinceQualified
<
6
*
day
{
...
@@ -106,15 +106,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -106,15 +106,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
_
app
:
UIApplication
,
open
url
:
URL
,
options
:
[
UIApplication
.
OpenURLOptionsKey
:
Any
]
=
[:])
->
Bool
{
func
application
(
_
app
:
UIApplication
,
open
url
:
URL
,
options
:
[
UIApplication
.
OpenURLOptionsKey
:
Any
]
=
[:])
->
Bool
{
log
.
info
(
"Open URL:
\(
url
)
with options:
\(
options
)
"
)
log
.
info
(
"Open URL:
\(
url
)
with options:
\(
options
)
"
)
//TODO: move to Router?
let
oneWeatherRouter
=
DeeplinksRouter
()
#if DEBUG
oneWeatherRouter
.
open
(
url
:
url
)
//TODO: REMOVE THIS'
//TODO: move to Router?
#warning("THIS IS A DEBUG-ONLY PIECE OF CODE! Not even temporary! Remove before making a production build.")
#else
#error("THIS IS A DEBUG-ONLY PIECE OF CODE! Not even temporary! Remove before making a production build.")
#endif
appsFlyer
.
handleOpen
(
url
,
options
:
options
)
return
true
return
true
}
}
...
@@ -166,3 +160,38 @@ extension AppDelegate: AppsFlyerLibDelegate {
...
@@ -166,3 +160,38 @@ extension AppDelegate: AppsFlyerLibDelegate {
appsFlyerLog
.
error
(
"app open attribution error:
\(
error
)
"
)
appsFlyerLog
.
error
(
"app open attribution error:
\(
error
)
"
)
}
}
}
}
extension
AppDelegate
:
DeepLinkDelegate
{
func
didResolveDeepLink
(
_
result
:
DeepLinkResult
)
{
switch
result
.
status
{
case
.
notFound
:
appsFlyerLog
.
info
(
"Deeplink: not found"
)
return
case
.
failure
:
if
let
error
=
result
.
error
{
appsFlyerLog
.
error
(
"Deeplink: error:
\(
error
)
"
)
}
else
{
appsFlyerLog
.
error
(
"Deeplink: error (unknown)"
)
}
return
case
.
found
:
appsFlyerLog
.
info
(
"Deeplink: found!"
)
}
guard
let
deepLinkObj
:
DeepLink
=
result
.
deepLink
else
{
appsFlyerLog
.
error
(
"Deeplink: Could not extract deep link object"
)
return
}
log
.
debug
(
"Deeplink: it's a
\(
deepLinkObj
.
isDeferred
?
"deferred"
:
"direct"
)
deeplink."
)
guard
let
deeplink
=
deepLinkObj
.
deeplinkValue
else
{
appsFlyerLog
.
error
(
"Deeplink: Could not extract deep_link_value from deep link object"
)
return
}
guard
let
url
=
URL
(
string
:
deeplink
)
else
{
appsFlyerLog
.
error
(
"Deeplink: Couldn't create a URL from deeplink:
\(
deeplink
)
"
)
return
}
let
router
=
DeeplinksRouter
()
router
.
open
(
url
:
url
)
}
}
1Weather/Coordinators/DeeplinksRouter.swift
View file @
c21e87c1
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
// Copyright © 2021 OneLouder, Inc. All rights reserved.
// Copyright © 2021 OneLouder, Inc. All rights reserved.
//
//
import
Foundation
import
UIKit
import
AppsFlyerLib
class
DeeplinksRouter
{
class
DeeplinksRouter
{
static
let
urlScheme
=
"oneweather"
static
let
urlScheme
=
"oneweather"
...
@@ -80,13 +81,17 @@ class DeeplinksRouter {
...
@@ -80,13 +81,17 @@ class DeeplinksRouter {
return
result
return
result
}
}
public
func
open
(
url
:
URL
)
{
public
func
open
(
url
:
URL
,
options
:
[
UIApplication
.
OpenURLOptionsKey
:
Any
]
=
[:]
)
{
guard
self
.
is1WUrl
(
url
)
else
{
guard
self
.
is1WUrl
(
url
)
else
{
log
.
info
(
"not 1Weather URL, ignore:
\(
url
)
"
)
log
.
info
(
"not 1Weather URL, trying AppsFlyer:
\(
url
)
"
)
AppsFlyerLib
.
shared
()
.
handleOpen
(
url
,
options
:
options
)
return
return
}
}
log
.
info
(
"open URL:
\(
url
)
"
)
log
.
info
(
"open
1Weather
URL:
\(
url
)
"
)
var
pathComponents
=
url
.
pathComponents
var
pathComponents
=
url
.
pathComponents
if
let
host
=
url
.
host
{
pathComponents
.
insert
(
host
,
at
:
0
)
}
while
let
currentComponent
=
pathComponents
.
popLast
()
{
while
let
currentComponent
=
pathComponents
.
popLast
()
{
if
let
parsedComponent
=
UrlPathComponent
(
rawValue
:
currentComponent
.
lowercased
())
{
if
let
parsedComponent
=
UrlPathComponent
(
rawValue
:
currentComponent
.
lowercased
())
{
log
.
debug
(
"Parsed path:
\(
parsedComponent
.
rawValue
)
"
)
log
.
debug
(
"Parsed path:
\(
parsedComponent
.
rawValue
)
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment