File tree Expand file tree Collapse file tree 10 files changed +381
-71
lines changed
OneSignalExample.xcodeproj
Assets.xcassets/onesignaldemo.imageset Expand file tree Collapse file tree 10 files changed +381
-71
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 22<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33<plist version =" 1.0" >
44<dict >
5+ <key >NSSupportsLiveActivities </key >
6+ <true />
57 <key >ITSAppUsesNonExemptEncryption </key >
68 <false />
79 <key >UIUserInterfaceStyle </key >
Original file line number Diff line number Diff line change 6464@property (weak , nonatomic ) IBOutlet UITextView *result;
6565@property (weak , nonatomic ) IBOutlet UITextField *tagKey;
6666@property (weak , nonatomic ) IBOutlet UITextField *tagValue;
67+ @property (weak , nonatomic ) IBOutlet UITextField *activityId;
6768
6869@end
6970
Original file line number Diff line number Diff line change 3030
3131#import " ViewController.h"
3232#import " AppDelegate.h"
33+ #import " OneSignalExample-Swift.h"
3334
3435@implementation ViewController
3536
@@ -201,4 +202,25 @@ - (IBAction)sendUniqueOutcomeEvent:(id)sender {
201202 [OneSignal.Session addUniqueOutcome: [_outcomeUniqueName text ]];
202203}
203204
205+ - (IBAction )startAndEnterLiveActivity : (id )sender {
206+ if (@available (iOS 13.0 , *)) {
207+ NSString *activityId = [self .activityId text ];
208+ // Will not make a live activity if activityId is empty
209+ if (activityId && activityId.length ) {
210+ [LiveActivityController createActivityWithCompletionHandler: ^(NSString * token) {
211+ if (token){
212+ [OneSignal enterLiveActivity: activityId withToken: token];
213+ }
214+ }];
215+ }
216+ } else {
217+ NSLog (@" Must use iOS 13 or later for swift concurrency which is required for [LiveActivityController createActivityWithCompletionHandler..." );
218+ }
219+ }
220+ - (IBAction )exitLiveActivity : (id )sender {
221+ if (self.activityId .text && self.activityId .text .length ) {
222+ [OneSignal exitLiveActivity: self .activityId.text];
223+ }
224+ }
225+
204226@end
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ {
2+ "images" : [
3+ {
4+ "idiom" : " universal" ,
5+ "scale" : " 1x"
6+ },
7+ {
8+ "idiom" : " universal" ,
9+ "scale" : " 2x"
10+ },
11+ {
12+ "filename" : " onesignal-logo.png" ,
13+ "idiom" : " universal" ,
14+ "scale" : " 3x"
15+ }
16+ ],
17+ "info" : {
18+ "author" : " xcode" ,
19+ "version" : 1
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import SwiftUI
1212@main
1313struct OneSignalWidgetExtensionBundle : WidgetBundle {
1414 var body : some Widget {
15- OneSignalWidgetExtension ( )
1615 OneSignalWidgetExtensionLiveActivity ( )
1716 }
1817}
Original file line number Diff line number Diff line change @@ -10,26 +10,31 @@ import ActivityKit
1010import WidgetKit
1111import SwiftUI
1212
13- struct OneSignalWidgetExtensionAttributes : ActivityAttributes {
14- public struct ContentState : Codable , Hashable {
15- // Dynamic stateful properties about your activity go here!
16- var value : Int
17- }
18-
19- // Fixed non-changing properties about your activity go here!
20- var name : String
21- }
2213
2314struct OneSignalWidgetExtensionLiveActivity : Widget {
2415 var body : some WidgetConfiguration {
25- ActivityConfiguration ( for: OneSignalWidgetExtensionAttributes . self) { context in
26- // Lock screen/banner UI goes here
16+ ActivityConfiguration ( for: OneSignalWidgetAttributes . self) { context in
17+ // Lock screen/banner UI goes here\VStack(alignment: .leading) {
2718 VStack {
28- Text ( " Hello " )
19+ Spacer ( )
20+ Text ( context. attributes. title) . font ( . headline)
21+ Spacer ( )
22+ HStack {
23+ Spacer ( )
24+ Label {
25+ Text ( context. state. message)
26+ } icon: {
27+ Image ( " onesignaldemo " )
28+ . resizable ( )
29+ . scaledToFit ( )
30+ . frame ( width: 40.0 , height: 40.0 )
31+ }
32+ Spacer ( )
33+ }
34+ Spacer ( )
2935 }
30- . activityBackgroundTint ( Color . cyan)
31- . activitySystemActionForegroundColor ( Color . black)
32-
36+ . activitySystemActionForegroundColor ( . black)
37+ . activityBackgroundTint ( . white)
3338 } dynamicIsland: { context in
3439 DynamicIsland {
3540 // Expanded UI goes here. Compose the expanded UI through
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33<plist version =" 1.0" >
4- <dict />
4+ <dict >
5+ <key >com.apple.security.app-sandbox</key >
6+ <true />
7+ <key >com.apple.security.network.client</key >
8+ <true />
9+ </dict >
510</plist >
You can’t perform that action at this time.
0 commit comments