Skip to content

Commit

Permalink
Merge pull request #742 from OneSignal/fix/macCatalyst
Browse files Browse the repository at this point in the history
[Fix] Mac Catalyst build errors
  • Loading branch information
shepherd-l authored Jul 3, 2024
2 parents 65abdaa + 8530e0e commit 98035f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Additional instance of OneSignal error when calling OneSignal methods in Awake()
- iOS Mac Catalyst build error: Use of undeclared identifier 'OneSignalLiveActivitiesManagerImpl'

## [5.1.6]
### Fixed
Expand Down
2 changes: 2 additions & 0 deletions OneSignalExample/iOS/ExampleWidget/ExampleWidgetBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Brian Smith on 5/29/24.
//

#if !targetEnvironment(macCatalyst)
import WidgetKit
import SwiftUI

Expand All @@ -14,3 +15,4 @@ struct ExampleWidgetBundle: WidgetBundle {
ExampleWidgetLiveActivity()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2024 The Chromium Authors. All rights reserved.
//

#if !targetEnvironment(macCatalyst)
import ActivityKit
import WidgetKit
import SwiftUI
Expand Down Expand Up @@ -64,3 +65,4 @@ struct ExampleWidgetLiveActivity: Widget {
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<dependencies>
<iosPods>
<iosPod name="OneSignalXCFramework" version="5.2.0" addToAllTargets="true" />
<iosPod name="OneSignalXCFramework" version="5.2.1" addToAllTargets="true" />
</iosPods>
</dependencies>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void _oneSignalExitLiveActivity(const char* activityId, int hashCode, BooleanRes


void _oneSignalSetupDefaultLiveActivity(const char* optionsJson) {
#if !TARGET_OS_MACCATALYST
LiveActivitySetupOptions *laOptions = nil;

if (optionsJson) {
Expand All @@ -77,9 +78,11 @@ void _oneSignalSetupDefaultLiveActivity(const char* optionsJson) {
} else {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setupDefault on iOS < 16.1"]];
}
#endif
}

void _oneSignalStartDefaultLiveActivity(const char* activityId, const char* attributesJson, const char* contentJson) {
#if !TARGET_OS_MACCATALYST
if (@available(iOS 16.1, *)) {
NSDictionary *attributes = oneSignalDictionaryFromJsonString(attributesJson);
NSDictionary *content = oneSignalDictionaryFromJsonString(contentJson);
Expand All @@ -88,9 +91,11 @@ void _oneSignalStartDefaultLiveActivity(const char* activityId, const char* attr
} else {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot startDefault on iOS < 16.1"]];
}
#endif
}

void _oneSignalSetPushToStartToken(const char* activityType, const char* token) {
#if !TARGET_OS_MACCATALYST
NSError* err=nil;

if (@available(iOS 17.2, *)) {
Expand All @@ -101,9 +106,11 @@ void _oneSignalSetPushToStartToken(const char* activityType, const char* token)
} else {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot setPushToStartToken on iOS < 17.2"]];
}
#endif
}

void _oneSignalRemovePushToStartToken(const char* activityType) {
#if !TARGET_OS_MACCATALYST
NSError* err=nil;
if (@available(iOS 17.2, *)) {
[OneSignalLiveActivitiesManagerImpl removePushToStartToken:TO_NSSTRING(activityType) error:&err];
Expand All @@ -114,5 +121,6 @@ void _oneSignalRemovePushToStartToken(const char* activityType) {
} else {
[OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"cannot removePushToStartToken on iOS < 17.2"]];
}
#endif
}
}

0 comments on commit 98035f6

Please sign in to comment.