Skip to content

Fix iOS Url Scheme issue #46 #47

@cemck

Description

@cemck

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-tiktok@2.1.16 for the project I'm working on.

Reference: #46

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-tiktok/plugin/build/withTiktok.js b/node_modules/react-native-tiktok/plugin/build/withTiktok.js
index 0003488..b5fc450 100644
--- a/node_modules/react-native-tiktok/plugin/build/withTiktok.js
+++ b/node_modules/react-native-tiktok/plugin/build/withTiktok.js
@@ -6,17 +6,24 @@ const withTiktok = (config, { tiktokClientKey }) => {
     config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
         // eslint-disable-next-line dot-notation
         config.modResults['TikTokClientKey'] = tiktokClientKey;
-        config.modResults.CFBundleURLTypes = [
-            {
-                CFBundleURLSchemes: [tiktokClientKey],
-            },
-        ];
-        config.modResults.LSApplicationQueriesSchemes = [
-            'tiktokopensdk',
-            'tiktoksharesdk',
-            'snssdk1180',
-            'snssdk1233',
-        ];
+        
+        // PATCHED: Append to existing URL schemes instead of overwriting
+        const existingURLTypes = config.modResults.CFBundleURLTypes || [];
+        existingURLTypes.push({
+            CFBundleURLSchemes: [tiktokClientKey],
+        });
+        config.modResults.CFBundleURLTypes = existingURLTypes;
+        
+        // PATCHED: Append to existing LSApplicationQueriesSchemes instead of overwriting
+        const existingSchemes = config.modResults.LSApplicationQueriesSchemes || [];
+        const tiktokSchemes = ['tiktokopensdk', 'tiktoksharesdk', 'snssdk1180', 'snssdk1233'];
+        for (const scheme of tiktokSchemes) {
+            if (!existingSchemes.includes(scheme)) {
+                existingSchemes.push(scheme);
+            }
+        }
+        config.modResults.LSApplicationQueriesSchemes = existingSchemes;
+        
         return config;
     });
     config = (0, config_plugins_1.withProjectBuildGradle)(config, (config) => {

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions