Skip to content

Commit 07508a1

Browse files
JonFJonF
authored andcommitted
Update Swift Example Project
1 parent 8029bd4 commit 07508a1

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

Examples/SwiftExample/OneSignalDemo.xcodeproj/project.pbxproj

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
isa = PBXProject;
211211
attributes = {
212212
LastSwiftUpdateCheck = 0820;
213-
LastUpgradeCheck = 0820;
213+
LastUpgradeCheck = 1140;
214214
ORGANIZATIONNAME = OneSignal;
215215
TargetAttributes = {
216216
9112E8AC1E725C1E0022A1CB = {
@@ -235,7 +235,7 @@
235235
};
236236
buildConfigurationList = 91E4D5081C7521DE00025BA8 /* Build configuration list for PBXProject "OneSignalDemo" */;
237237
compatibilityVersion = "Xcode 3.2";
238-
developmentRegion = English;
238+
developmentRegion = en;
239239
hasScannedForEncodings = 0;
240240
knownRegions = (
241241
en,
@@ -422,7 +422,7 @@
422422
PRODUCT_NAME = "$(TARGET_NAME)";
423423
SKIP_INSTALL = YES;
424424
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
425-
SWIFT_VERSION = 3.0;
425+
SWIFT_VERSION = 5.0;
426426
};
427427
name = Debug;
428428
};
@@ -442,26 +442,35 @@
442442
PRODUCT_NAME = "$(TARGET_NAME)";
443443
SKIP_INSTALL = YES;
444444
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
445-
SWIFT_VERSION = 3.0;
445+
SWIFT_VERSION = 5.0;
446446
};
447447
name = Release;
448448
};
449449
91E4D51D1C7521DE00025BA8 /* Debug */ = {
450450
isa = XCBuildConfiguration;
451451
buildSettings = {
452452
ALWAYS_SEARCH_USER_PATHS = NO;
453+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
453454
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
454455
CLANG_CXX_LIBRARY = "libc++";
455456
CLANG_ENABLE_MODULES = YES;
456457
CLANG_ENABLE_OBJC_ARC = YES;
458+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
457459
CLANG_WARN_BOOL_CONVERSION = YES;
460+
CLANG_WARN_COMMA = YES;
458461
CLANG_WARN_CONSTANT_CONVERSION = YES;
462+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
459463
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
460464
CLANG_WARN_EMPTY_BODY = YES;
461465
CLANG_WARN_ENUM_CONVERSION = YES;
462466
CLANG_WARN_INFINITE_RECURSION = YES;
463467
CLANG_WARN_INT_CONVERSION = YES;
468+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
469+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
470+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
464471
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
472+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
473+
CLANG_WARN_STRICT_PROTOTYPES = YES;
465474
CLANG_WARN_SUSPICIOUS_MOVE = YES;
466475
CLANG_WARN_UNREACHABLE_CODE = YES;
467476
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -497,18 +506,27 @@
497506
isa = XCBuildConfiguration;
498507
buildSettings = {
499508
ALWAYS_SEARCH_USER_PATHS = NO;
509+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
500510
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
501511
CLANG_CXX_LIBRARY = "libc++";
502512
CLANG_ENABLE_MODULES = YES;
503513
CLANG_ENABLE_OBJC_ARC = YES;
514+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
504515
CLANG_WARN_BOOL_CONVERSION = YES;
516+
CLANG_WARN_COMMA = YES;
505517
CLANG_WARN_CONSTANT_CONVERSION = YES;
518+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
506519
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
507520
CLANG_WARN_EMPTY_BODY = YES;
508521
CLANG_WARN_ENUM_CONVERSION = YES;
509522
CLANG_WARN_INFINITE_RECURSION = YES;
510523
CLANG_WARN_INT_CONVERSION = YES;
524+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
525+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
526+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
511527
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
528+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
529+
CLANG_WARN_STRICT_PROTOTYPES = YES;
512530
CLANG_WARN_SUSPICIOUS_MOVE = YES;
513531
CLANG_WARN_UNREACHABLE_CODE = YES;
514532
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -546,7 +564,7 @@
546564
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
547565
PRODUCT_NAME = "$(TARGET_NAME)";
548566
SWIFT_OBJC_BRIDGING_HEADER = "";
549-
SWIFT_VERSION = 3.0;
567+
SWIFT_VERSION = 5.0;
550568
};
551569
name = Debug;
552570
};
@@ -562,7 +580,7 @@
562580
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example;
563581
PRODUCT_NAME = "$(TARGET_NAME)";
564582
SWIFT_OBJC_BRIDGING_HEADER = "";
565-
SWIFT_VERSION = 3.0;
583+
SWIFT_VERSION = 5.0;
566584
};
567585
name = Release;
568586
};

Examples/SwiftExample/OneSignalDemo.xcodeproj/xcshareddata/xcschemes/OneSignalDemo.xcscheme

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "1140"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,10 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
3029
shouldUseLaunchSchemeArgsEnv = "YES">
31-
<Testables>
32-
</Testables>
3330
<MacroExpansion>
3431
<BuildableReference
3532
BuildableIdentifier = "primary"
@@ -39,14 +36,13 @@
3936
ReferencedContainer = "container:OneSignalDemo.xcodeproj">
4037
</BuildableReference>
4138
</MacroExpansion>
42-
<AdditionalOptions>
43-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4441
</TestAction>
4542
<LaunchAction
4643
buildConfiguration = "Debug"
4744
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4845
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49-
language = ""
5046
launchStyle = "0"
5147
useCustomWorkingDirectory = "NO"
5248
ignoresPersistentStateOnLaunch = "NO"
@@ -63,8 +59,6 @@
6359
ReferencedContainer = "container:OneSignalDemo.xcodeproj">
6460
</BuildableReference>
6561
</BuildableProductRunnable>
66-
<AdditionalOptions>
67-
</AdditionalOptions>
6862
</LaunchAction>
6963
<ProfileAction
7064
buildConfiguration = "Release"

Examples/SwiftExample/OneSignalDemo.xcodeproj/xcshareddata/xcschemes/OneSignalNotificationServiceExtension.xcscheme

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "1140"
44
wasCreatedForAppExtension = "YES"
55
version = "2.0">
66
<BuildAction
@@ -42,8 +42,6 @@
4242
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4343
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4444
shouldUseLaunchSchemeArgsEnv = "YES">
45-
<Testables>
46-
</Testables>
4745
<MacroExpansion>
4846
<BuildableReference
4947
BuildableIdentifier = "primary"
@@ -53,14 +51,15 @@
5351
ReferencedContainer = "container:OneSignalDemo.xcodeproj">
5452
</BuildableReference>
5553
</MacroExpansion>
56-
<AdditionalOptions>
57-
</AdditionalOptions>
54+
<Testables>
55+
</Testables>
5856
</TestAction>
5957
<LaunchAction
6058
buildConfiguration = "Debug"
6159
selectedDebuggerIdentifier = ""
6260
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
6361
launchStyle = "0"
62+
askForAppToLaunch = "Yes"
6463
useCustomWorkingDirectory = "NO"
6564
ignoresPersistentStateOnLaunch = "NO"
6665
debugDocumentVersioning = "YES"
@@ -77,8 +76,6 @@
7776
ReferencedContainer = "container:OneSignalDemo.xcodeproj">
7877
</BuildableReference>
7978
</BuildableProductRunnable>
80-
<AdditionalOptions>
81-
</AdditionalOptions>
8279
</LaunchAction>
8380
<ProfileAction
8481
buildConfiguration = "Release"

Examples/SwiftExample/OneSignalDemo/AppDelegate.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,31 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OSPermissionObserver, OSS
3838
let redViewController = RedViewController()
3939
let greenViewController = GreenViewController()
4040

41-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
41+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4242

4343
// For debugging
44-
//OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
44+
OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
4545

4646
let notificationReceivedBlock: OSHandleNotificationReceivedBlock = { notification in
4747

48-
print("Received Notification: \(notification!.payload.notificationID)")
49-
print("launchURL = \(notification?.payload.launchURL ?? "None")")
48+
print("Received Notification: ", notification!.payload.notificationID!)
49+
print("launchURL: ", notification?.payload.launchURL ?? "No Launch Url")
5050
print("content_available = \(notification?.payload.contentAvailable ?? false)")
5151
}
5252

5353
let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
5454
// This block gets called when the user reacts to a notification received
5555
let payload: OSNotificationPayload? = result?.notification.payload
5656

57-
print("Message = \(payload!.body)")
58-
print("badge number = \(payload?.badge ?? 0)")
59-
print("notification sound = \(payload?.sound ?? "None")")
57+
print("Message: ", payload!.body!)
58+
print("badge number: ", payload?.badge ?? 0)
59+
print("notification sound: ", payload?.sound ?? "No sound")
6060

6161
if let additionalData = result!.notification.payload!.additionalData {
62-
print("additionalData = \(additionalData)")
63-
62+
print("additionalData: ", additionalData)
6463

6564
if let actionSelected = payload?.actionButtons {
66-
print("actionSelected = \(actionSelected)")
65+
print("actionSelected: ", actionSelected)
6766
}
6867

6968
// DEEP LINK from action buttons
@@ -92,10 +91,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OSPermissionObserver, OSS
9291
}
9392
}
9493
}
95-
94+
9695
let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false, kOSSettingsKeyInAppLaunchURL: true, ]
9796

98-
OneSignal.initWithLaunchOptions(launchOptions, appId: "b2f7f966-d8cc-11e4-bed1-df8f05be55ba", handleNotificationReceived: notificationReceivedBlock, handleNotificationAction: notificationOpenedBlock, settings: onesignalInitSettings)
97+
OneSignal.initWithLaunchOptions(launchOptions, appId: "3beb3078-e0f1-4629-af17-fde833b9f716", handleNotificationReceived: notificationReceivedBlock, handleNotificationAction: notificationOpenedBlock, settings: onesignalInitSettings)
9998

10099
OneSignal.inFocusDisplayType = OSNotificationDisplayType.notification
101100

@@ -119,7 +118,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OSPermissionObserver, OSS
119118
}
120119
}
121120
// prints out all properties
122-
print("PermissionStateChanges: \n\(stateChanges)")
121+
print("PermissionStateChanges: ", stateChanges!)
123122
}
124123

125124
// Output:
@@ -138,7 +137,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, OSPermissionObserver, OSS
138137
if !stateChanges.from.subscribed && stateChanges.to.subscribed {
139138
print("Subscribed for OneSignal push notifications!")
140139
}
141-
print("SubscriptionStateChange: \n\(stateChanges)")
140+
print("SubscriptionStateChange: ", stateChanges!)
142141
}
143142

144143
// Output:

0 commit comments

Comments
 (0)