-
Notifications
You must be signed in to change notification settings - Fork 221
Expand file tree
/
Copy pathwithAppsFlyerAndroid.js
More file actions
32 lines (28 loc) · 1.06 KB
/
withAppsFlyerAndroid.js
File metadata and controls
32 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {withMainActivity} = require('@expo/config-plugins')
function overrideOnNewIntent(contents, packageName = ''){
let nextContent = contents
const intentImportString = 'import android.content.Intent'
if (!nextContent.includes(intentImportString)){
const packageString = `${packageName}\n`
nextContent = nextContent.replace(packageString,`${packageString}\n${intentImportString}`)
}
if (!nextContent.includes('override fun onNewIntent(intent: Intent?)')) {
const classDeclarationRegex = /class\s+\w+.*\{/
nextContent = nextContent.replace(
classDeclarationRegex,
match=>`${match}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
setIntent(intent)
}
`)
}
return nextContent
}
module.exports = function withAppsFlyerAndroid(config){
return withMainActivity(config, function(config){
const {modResults:{contents},android} = config
config.modResults.contents = overrideOnNewIntent(contents,android?.package)
return config
})
}