@@ -2,24 +2,51 @@ const { withAppDelegate } = require('@expo/config-plugins')
22
33const generateCode = require ( '@expo/config-plugins/build/utils/generateCode' )
44
5+ function selectStrings ( language ) {
6+ if ( language === 'swift' ) {
7+ return {
8+ import : {
9+ anchor : / i m p o r t \s + E x p o / ,
10+ newSrc : 'import react_native_line' ,
11+ } ,
12+ return : {
13+ anchor : / r e t u r n \s + s u p e r \. a p p l i c a t i o n \( \s * a p p , \s * o p e n : \s * u r l , \s * o p t i o n s : \s * o p t i o n s \s * \) \s * \| \| \s * R C T L i n k i n g M a n a g e r \. a p p l i c a t i o n \( \s * a p p , \s * o p e n : \s * u r l , \s * o p t i o n s : \s * o p t i o n s \s * \) / ,
14+ newSrc : ' return LineLogin.application(app, open: url, options: options)' ,
15+ offset : 0 ,
16+ } ,
17+ }
18+ } else {
19+ return {
20+ import : {
21+ anchor : / # i m p o r t \s + " A p p D e l e g a t e \. h " / ,
22+ newSrc : '#import "react_native_line-Swift.h"' ,
23+ } ,
24+ return : {
25+ anchor : / - \s * \( B O O L \) \s * a p p l i c a t i o n : \s * \( U I A p p l i c a t i o n \s * \* \) \s * a p p l i c a t i o n \s + o p e n U R L : \s * \( N S U R L \s * \* \) \s * u r l \s + o p t i o n s : \s * \( N S D i c t i o n a r y < U I A p p l i c a t i o n O p e n U R L O p t i o n s K e y , \s * i d > \s * \* \) \s * o p t i o n s \s * \{ / ,
26+ newSrc : ' return [LineLogin application:application open:url options:options];' ,
27+ } ,
28+ }
29+ }
30+ }
31+
532function withCustomAppDelegate ( config ) {
633 return withAppDelegate ( config , config => {
34+ const strings = selectStrings ( config . modResults . language )
35+
736 const withImport = generateCode . mergeContents ( {
837 comment : '//' ,
9- anchor : / # i m p o r t " A p p D e l e g a t e \. h " / ,
10- newSrc : '#import "react_native_line-Swift.h"' ,
1138 offset : 1 ,
1239 src : config . modResults . contents ,
1340 tag : 'import' ,
41+ ...strings . import ,
1442 } )
1543
1644 const withOpenUrl = generateCode . mergeContents ( {
1745 comment : '//' ,
18- anchor : / - \( B O O L \) a p p l i c a t i o n : \( U I A p p l i c a t i o n \* \) a p p l i c a t i o n o p e n U R L : \( N S U R L \* \) u r l o p t i o n s : \( N S D i c t i o n a r y < U I A p p l i c a t i o n O p e n U R L O p t i o n s K e y , i d > \* \) o p t i o n s { / ,
19- newSrc : 'return [LineLogin application:application open:url options:options];' ,
2046 offset : 1 ,
2147 src : withImport . contents ,
22- tag : 'return' ,
48+ tag : 'linking' ,
49+ ...strings . return ,
2350 } )
2451
2552 return {
0 commit comments