Update withAppDelegateReferrer.js
This commit is contained in:
@@ -1,41 +1,41 @@
|
|||||||
const {withAppDelegate} = require('@expo/config-plugins')
|
const {withAppDelegate} = require('@expo/config-plugins')
|
||||||
const {mergeContents} = require('@expo/config-plugins/build/utils/generateCode')
|
const {mergeContents} = require('@expo/config-plugins/build/utils/generateCode')
|
||||||
const path = require('path')
|
|
||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
module.exports = config => {
|
module.exports = config =>
|
||||||
// eslint-disable-next-line no-shadow
|
withAppDelegate(config, config => {
|
||||||
return withAppDelegate(config, async config => {
|
let contents = config.modResults.contents
|
||||||
const delegatePath = path.join(
|
|
||||||
config.modRequest.platformProjectRoot,
|
|
||||||
'AppDelegate.mm',
|
|
||||||
)
|
|
||||||
|
|
||||||
let newContents = config.modResults.contents
|
contents = mergeContents({
|
||||||
newContents = mergeContents({
|
src: contents,
|
||||||
src: newContents,
|
|
||||||
anchor: '// Linking API',
|
anchor: '// Linking API',
|
||||||
newSrc: `
|
newSrc: `
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
// @generated begin referrer info – deep links
|
||||||
[defaults setObject:options[UIApplicationOpenURLOptionsSourceApplicationKey] forKey:@"referrerApp"];\n`,
|
let defaults = UserDefaults.standard
|
||||||
offset: 2,
|
defaults.set(
|
||||||
|
options[.sourceApplication] as? String,
|
||||||
|
forKey: "referrerApp"
|
||||||
|
)
|
||||||
|
// @generated end referrer info – deep links
|
||||||
|
`,
|
||||||
|
offset: 6,
|
||||||
tag: 'referrer info - deep links',
|
tag: 'referrer info - deep links',
|
||||||
comment: '//',
|
comment: '//',
|
||||||
}).contents
|
}).contents
|
||||||
|
|
||||||
newContents = mergeContents({
|
contents = mergeContents({
|
||||||
src: newContents,
|
src: contents,
|
||||||
anchor: '// Universal Links',
|
anchor: '// Universal Links',
|
||||||
newSrc: `
|
newSrc: `
|
||||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
// @generated begin referrer info – universal links
|
||||||
[defaults setURL:userActivity.referrerURL forKey:@"referrer"];\n`,
|
let defaults = UserDefaults.standard
|
||||||
offset: 2,
|
defaults.set(userActivity.referrerURL, forKey: "referrer")
|
||||||
|
// @generated end referrer info – universal links
|
||||||
|
`,
|
||||||
|
offset: 6,
|
||||||
tag: 'referrer info - universal links',
|
tag: 'referrer info - universal links',
|
||||||
comment: '//',
|
comment: '//',
|
||||||
}).contents
|
}).contents
|
||||||
|
|
||||||
config.modResults.contents = newContents
|
config.modResults.contents = contents
|
||||||
|
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user