Skip to content

Commit 36f771d

Browse files
committed
fix(demo): address second round of PR review feedback
- URI-escape activityId in Live Activity API URL - Fix .env parser: strip inline comments before quotes - Include all content state fields in End event_updates - Clean up stale .meta file when deleting .env from StreamingAssets Made-with: Cursor fix(demo): restrict .env copy to iOS builds only Made-with: Cursor fix(demo): copy .env for all build platforms
1 parent 2ba66dc commit 36f771d

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

examples/demo/Assets/Scripts/Editor/CopyEnvPreBuild.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ public void OnPreprocessBuild(BuildReport report)
2424
+ "Copy .env.example to .env and add your key."
2525
);
2626
if (File.Exists(dest))
27+
{
2728
File.Delete(dest);
29+
var metaPath = dest + ".meta";
30+
if (File.Exists(metaPath))
31+
File.Delete(metaPath);
32+
}
2833
return;
2934
}
3035

examples/demo/Assets/Scripts/Services/OneSignalApiService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ public void LoadApiKey()
4242

4343
var eqIndex = trimmed.IndexOf('=');
4444
var key = trimmed.Substring(0, eqIndex).Trim();
45-
var value = trimmed.Substring(eqIndex + 1).Trim().Trim('"', '\'');
45+
var value = trimmed.Substring(eqIndex + 1).Trim();
4646
int commentIdx = value.IndexOf('#');
4747
if (commentIdx >= 0)
4848
value = value.Substring(0, commentIdx).Trim();
49+
value = value.Trim('"', '\'');
4950

5051
if (key == "ONESIGNAL_API_KEY")
5152
_apiKey = value;
@@ -154,8 +155,9 @@ public async Task<bool> UpdateLiveActivity(
154155
if (string.IsNullOrEmpty(activityId) || string.IsNullOrEmpty(_appId) || !HasApiKey())
155156
return false;
156157

158+
var encodedId = Uri.EscapeDataString(activityId);
157159
var url =
158-
$"https://api.onesignal.com/apps/{_appId}/live_activities/{activityId}/notifications";
160+
$"https://api.onesignal.com/apps/{_appId}/live_activities/{encodedId}/notifications";
159161

160162
var payload = new JObject
161163
{

examples/demo/Assets/Scripts/ViewModels/AppViewModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,12 @@ public async void EndLiveActivity(string activityId)
472472
{
473473
var eventUpdates = new JObject
474474
{
475-
["data"] = new JObject { ["message"] = "Ended" },
475+
["data"] = new JObject
476+
{
477+
["status"] = "delivered",
478+
["message"] = "Ended",
479+
["estimatedTime"] = "",
480+
},
476481
};
477482

478483
bool success = await _repository.UpdateLiveActivity(activityId, "end", eventUpdates);

0 commit comments

Comments
 (0)