Skip to content

Commit 6ed6cf1

Browse files
committed
chore(ios): for demo; updates OneSignal extension and deployment target
1 parent ac8e6bd commit 6ed6cf1

42 files changed

Lines changed: 2921 additions & 302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

com.onesignal.unity.ios/Editor/BuildPostProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private void AddNotificationServiceExtension()
221221

222222
// Makes it so that the extension target is Universal (not just iPhone) and has an iOS 10 deployment target
223223
_project.SetBuildProperty(extensionGuid, "TARGETED_DEVICE_FAMILY", "1,2");
224-
_project.SetBuildProperty(extensionGuid, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");
224+
_project.SetBuildProperty(extensionGuid, "IPHONEOS_DEPLOYMENT_TARGET", "13.0");
225225
_project.SetBuildProperty(extensionGuid, "SWIFT_VERSION", "5.0");
226226
_project.SetBuildProperty(extensionGuid, "ARCHS", "arm64");
227227
_project.SetBuildProperty(
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import UserNotifications
2-
import OneSignalFramework
2+
import OneSignalExtension
33

44
class NotificationService: UNNotificationServiceExtension {
55
var contentHandler: ((UNNotificationContent) -> Void)?
66
var receivedRequest: UNNotificationRequest!
77
var bestAttemptContent: UNMutableNotificationContent?
8-
8+
99
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
1010
self.receivedRequest = request
1111
self.contentHandler = contentHandler
1212
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
13-
13+
1414
if let bestAttemptContent = bestAttemptContent {
15-
OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
15+
OneSignalExtension.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
1616
}
1717
}
18-
18+
1919
override func serviceExtensionTimeWillExpire() {
20-
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
21-
OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
20+
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
21+
OneSignalExtension.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
2222
contentHandler(bestAttemptContent)
2323
}
24-
}
24+
}
2525
}

examples/build.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,18 @@ Android status bar:
132132
clearFlags removes the translucent override, setStatusBarColor sets the color
133133
- The app viewport sits below the system status bar; no spacer needed on Android
134134

135-
Run generate-icons.sh to download the padded app icon and produce Android
136-
launcher icons at all mipmap densities. The script creates an androidlib at
137-
Assets/Plugins/Android/AppIcon.androidlib/ that Unity merges into the Gradle
138-
build, replacing the default icon. Source icon:
135+
Run generate-icons.sh to download the padded app icon and produce platform icons.
136+
Source icon:
139137
https://raw.githubusercontent.com/OneSignal/sdk-shared/refs/heads/main/assets/onesignal_logo_icon_padded.png
140-
For iOS, set the icon manually in Project Settings > Player.
138+
139+
Android: the script creates an androidlib at
140+
Assets/Plugins/Android/AppIcon.androidlib/ that Unity merges into the Gradle
141+
build, replacing the default icon.
142+
143+
iOS: the script generates icons at all required sizes into Assets/AppIcons/iOS/,
144+
flattened onto a white background. A build post-processor
145+
(Assets/App/Editor/iOS/IconSetter.cs) copies them into the Xcode project's
146+
AppIcon.appiconset with a complete Contents.json at build time.
141147

142148
Reference the OneSignal Unity SDK from the parent repo using a local path dependency
143149
in Packages/manifest.json:

examples/build_ios_push.md

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#if UNITY_IOS
2+
3+
using System.IO;
4+
using UnityEditor.Build;
5+
using UnityEditor.Build.Reporting;
6+
using UnityEngine;
7+
8+
namespace App.Editor.iOS
9+
{
10+
public class IconSetter : IPostprocessBuildWithReport
11+
{
12+
private const string SourceDirectory = "Assets/AppIcons/iOS";
13+
14+
public int callbackOrder => 46;
15+
16+
public void OnPostprocessBuild(BuildReport report)
17+
{
18+
if (report.summary.platform != UnityEditor.BuildTarget.iOS)
19+
return;
20+
21+
var appiconsetPath = Path.Combine(
22+
report.summary.outputPath,
23+
"Unity-iPhone",
24+
"Images.xcassets",
25+
"AppIcon.appiconset"
26+
);
27+
28+
if (!Directory.Exists(appiconsetPath))
29+
{
30+
Debug.LogWarning($"IconSetter: {appiconsetPath} not found");
31+
return;
32+
}
33+
34+
var sourceDir = Path.Combine(Directory.GetCurrentDirectory(), SourceDirectory);
35+
if (!Directory.Exists(sourceDir))
36+
{
37+
Debug.LogWarning($"IconSetter: {sourceDir} not found, run generate-icons.sh first");
38+
return;
39+
}
40+
41+
foreach (var src in Directory.GetFiles(sourceDir, "icon_*.png"))
42+
{
43+
var dest = Path.Combine(appiconsetPath, Path.GetFileName(src));
44+
File.Copy(src, dest, true);
45+
}
46+
47+
var contentsJson = @"{
48+
""images"" : [
49+
{ ""filename"" : ""icon_120.png"", ""idiom"" : ""iphone"", ""scale"" : ""2x"", ""size"" : ""60x60"" },
50+
{ ""filename"" : ""icon_180.png"", ""idiom"" : ""iphone"", ""scale"" : ""3x"", ""size"" : ""60x60"" },
51+
{ ""filename"" : ""icon_80.png"", ""idiom"" : ""iphone"", ""scale"" : ""2x"", ""size"" : ""40x40"" },
52+
{ ""filename"" : ""icon_120.png"", ""idiom"" : ""iphone"", ""scale"" : ""3x"", ""size"" : ""40x40"" },
53+
{ ""filename"" : ""icon_58.png"", ""idiom"" : ""iphone"", ""scale"" : ""2x"", ""size"" : ""29x29"" },
54+
{ ""filename"" : ""icon_87.png"", ""idiom"" : ""iphone"", ""scale"" : ""3x"", ""size"" : ""29x29"" },
55+
{ ""filename"" : ""icon_40.png"", ""idiom"" : ""iphone"", ""scale"" : ""2x"", ""size"" : ""20x20"" },
56+
{ ""filename"" : ""icon_60.png"", ""idiom"" : ""iphone"", ""scale"" : ""3x"", ""size"" : ""20x20"" },
57+
{ ""filename"" : ""icon_76.png"", ""idiom"" : ""ipad"", ""scale"" : ""1x"", ""size"" : ""76x76"" },
58+
{ ""filename"" : ""icon_152.png"", ""idiom"" : ""ipad"", ""scale"" : ""2x"", ""size"" : ""76x76"" },
59+
{ ""filename"" : ""icon_167.png"", ""idiom"" : ""ipad"", ""scale"" : ""2x"", ""size"" : ""83.5x83.5"" },
60+
{ ""filename"" : ""icon_40.png"", ""idiom"" : ""ipad"", ""scale"" : ""1x"", ""size"" : ""40x40"" },
61+
{ ""filename"" : ""icon_80.png"", ""idiom"" : ""ipad"", ""scale"" : ""2x"", ""size"" : ""40x40"" },
62+
{ ""filename"" : ""icon_29.png"", ""idiom"" : ""ipad"", ""scale"" : ""1x"", ""size"" : ""29x29"" },
63+
{ ""filename"" : ""icon_58.png"", ""idiom"" : ""ipad"", ""scale"" : ""2x"", ""size"" : ""29x29"" },
64+
{ ""filename"" : ""icon_20.png"", ""idiom"" : ""ipad"", ""scale"" : ""1x"", ""size"" : ""20x20"" },
65+
{ ""filename"" : ""icon_40.png"", ""idiom"" : ""ipad"", ""scale"" : ""2x"", ""size"" : ""20x20"" },
66+
{ ""filename"" : ""icon_1024.png"",""idiom"" : ""ios-marketing"", ""scale"" : ""1x"", ""size"" : ""1024x1024"" }
67+
],
68+
""info"" : { ""author"" : ""xcode"", ""version"" : 1 }
69+
}";
70+
71+
File.WriteAllText(Path.Combine(appiconsetPath, "Contents.json"), contentsJson);
72+
Debug.Log("IconSetter: iOS app icons written to AppIcon.appiconset");
73+
}
74+
}
75+
}
76+
77+
#endif

examples/demo/Assets/App/Editor/iOS/IconSetter.cs.meta

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

0 commit comments

Comments
 (0)