Skip to content

Commit a5d6d46

Browse files
Added a check to see if the URL scheme is lowercase; if not, log an error and open our warning popup to indicate that using uppercase characters in the URL scheme may lead to deeplinking issues on certain platforms (e.g. Android) (#293)
1 parent 7c66485 commit a5d6d46

File tree

5 files changed

+110
-44
lines changed

5 files changed

+110
-44
lines changed

Packages/Sequence-Unity/Editor/AndroidCustomGradleCheck.cs

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class AndroidCustomGradleCheck : IPreprocessBuildWithReport
1515

1616
private static List<string> _cachedWarnings;
1717

18-
private const string _docsUrl = "https://docs.sequence.xyz/sdk/unity/recovering-sessions#android";
18+
private const string _docsUrl = "https://docs.sequence.xyz/sdk/unity/onboard/recovering-sessions#android";
1919

2020
public void OnPreprocessBuild(BuildReport report)
2121
{
@@ -48,7 +48,7 @@ public void OnPreprocessBuild(BuildReport report)
4848

4949
if (warnings.Count > 0)
5050
{
51-
WarningPopup.ShowWindow(warnings);
51+
SequenceWarningPopup.ShowWindow(warnings, _docsUrl);
5252
}
5353
}
5454
}
@@ -84,44 +84,5 @@ private bool GetProjectSettingsFlag(string key)
8484

8585
return false;
8686
}
87-
88-
private class WarningPopup : EditorWindow
89-
{
90-
private static List<string> warnings;
91-
92-
public static void ShowWindow(List<string> warningsToShow)
93-
{
94-
if (warningsToShow == null || warningsToShow.Count == 0)
95-
{
96-
return;
97-
}
98-
warnings = warningsToShow;
99-
var window = GetWindow<WarningPopup>("Sequence Build Warnings");
100-
window.position = new Rect(Screen.width / 2, Screen.height / 2, 400, 200);
101-
window.Show();
102-
}
103-
104-
private void OnGUI()
105-
{
106-
GUILayout.Label("Warnings Detected", EditorStyles.boldLabel);
107-
108-
foreach (string warning in warnings)
109-
{
110-
EditorGUILayout.HelpBox(warning, MessageType.Warning);
111-
112-
if (GUILayout.Button("Learn More", GUILayout.Width(100)))
113-
{
114-
Application.OpenURL(_docsUrl);
115-
}
116-
}
117-
118-
GUILayout.FlexibleSpace();
119-
120-
if (GUILayout.Button("Dismiss", GUILayout.Height(30)))
121-
{
122-
Close();
123-
}
124-
}
125-
}
12687
}
12788
}

Packages/Sequence-Unity/Editor/CheckUrlScheme.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
using Sequence.Config;
44
using UnityEditor;
55
using UnityEditor.Build;
6+
using UnityEditor.Build.Reporting;
67
using UnityEditor.Callbacks;
78
using UnityEngine;
8-
#if UNITY_IOS || UNITY_STANDALONE_OSX
99
using System.Collections.Generic;
10+
#if UNITY_IOS || UNITY_STANDALONE_OSX
1011
using UnityEditor.iOS.Xcode;
1112
#endif
1213

1314
namespace Sequence.Editor
1415
{
15-
public class CheckUrlScheme
16+
public class CheckUrlScheme : IPreprocessBuildWithReport
1617
{
1718
private static string _plistPath;
1819
private static string _urlScheme;
@@ -91,5 +92,34 @@ private static void CheckPlistUrlScheme()
9192
}
9293
#endif
9394
}
95+
96+
public int callbackOrder => 0;
97+
public void OnPreprocessBuild(BuildReport report)
98+
{
99+
SequenceConfig config = SequenceConfig.GetConfig();
100+
_urlScheme = config.UrlScheme;
101+
102+
List<string> warnings = new List<string>();
103+
104+
if (string.IsNullOrWhiteSpace(_urlScheme))
105+
{
106+
warnings.Add(SequenceConfig.MissingConfigError("Url Scheme").Message);
107+
}
108+
109+
if (_urlScheme.ToLower() != _urlScheme)
110+
{
111+
warnings.Add($"{nameof(config.UrlScheme)} should be all lowercase; if uppercase characters are included, you may encounter difficulties with deep-linking on certain platforms.");
112+
}
113+
114+
if (warnings.Count > 0)
115+
{
116+
foreach (var warning in warnings)
117+
{
118+
Debug.LogWarning(warning);
119+
}
120+
121+
SequenceWarningPopup.ShowWindow(warnings, "https://docs.sequence.xyz/sdk/unity/onboard/authentication/oidc");
122+
}
123+
}
94124
}
95125
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Collections.Generic;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
namespace Sequence.Editor
6+
{
7+
internal class SequenceWarningPopup : EditorWindow
8+
{
9+
private class Warning
10+
{
11+
public string WarningMessage;
12+
public string RelatedDocsUrl;
13+
14+
public Warning(string warningMessage, string relatedDocsUrl)
15+
{
16+
WarningMessage = warningMessage;
17+
RelatedDocsUrl = relatedDocsUrl;
18+
}
19+
}
20+
21+
private static List<Warning> warnings = new List<Warning>();
22+
23+
public static void ShowWindow(List<string> warningsToShow, string docsUrl)
24+
{
25+
if (warningsToShow == null || warningsToShow.Count == 0)
26+
{
27+
return;
28+
}
29+
30+
List<Warning> warningsToAdd = new List<Warning>();
31+
foreach (var warning in warningsToShow)
32+
{
33+
warningsToAdd.Add(new Warning(warning, docsUrl));
34+
}
35+
36+
if (warnings.Count > 0)
37+
{
38+
warnings.AddRange(warningsToAdd);
39+
}
40+
else
41+
{
42+
warnings = warningsToAdd;
43+
}
44+
var window = GetWindow<SequenceWarningPopup>("Sequence Build Warnings");
45+
window.position = new Rect(Screen.width / 2, Screen.height / 2, 400, 200);
46+
window.Show();
47+
}
48+
49+
private void OnGUI()
50+
{
51+
GUILayout.Label("Warnings Detected", EditorStyles.boldLabel);
52+
53+
foreach (Warning warning in warnings)
54+
{
55+
EditorGUILayout.HelpBox(warning.WarningMessage, MessageType.Warning);
56+
57+
if (GUILayout.Button("Learn More", GUILayout.Width(100)))
58+
{
59+
Application.OpenURL(warning.RelatedDocsUrl);
60+
}
61+
}
62+
63+
GUILayout.FlexibleSpace();
64+
65+
if (GUILayout.Button("Dismiss", GUILayout.Height(30)))
66+
{
67+
warnings = new List<Warning>();
68+
Close();
69+
}
70+
}
71+
}
72+
}

Packages/Sequence-Unity/Editor/SequenceWarningPopup.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/Sequence-Unity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xyz.0xsequence.waas-unity",
3-
"version": "4.1.0",
3+
"version": "4.1.1",
44
"displayName": "Sequence Embedded Wallet SDK",
55
"description": "A Unity SDK for Sequence APIs",
66
"unity": "2021.3",

0 commit comments

Comments
 (0)