From 0ba7ad5fdaec7e23e2e399d24b49a8a8d0a2ab23 Mon Sep 17 00:00:00 2001 From: Nan Date: Thu, 22 Aug 2024 10:52:03 -0700 Subject: [PATCH] internal dump method helper * internal for now, put in information you want to log for each product that conforms to OSLoggable --- .../OneSignalDevApp/SwiftTest.swift | 1 + .../OneSignalDevApp/ViewController.m | 1 + .../OneSignal.xcodeproj/project.pbxproj | 4 +++ .../OneSignalCore/Source/OneSignalLog.h | 3 +- .../OneSignalCore/Source/OneSignalLog.m | 6 ++++ .../OneSignalOSCore/Source/OSLoggable.swift | 30 +++++++++++++++++++ .../Source/OSOperationExecutor.swift | 2 +- .../Source/OSOperationRepo.swift | 6 ++++ .../OSIdentityOperationExecutor.swift | 6 ++++ .../OSPropertyOperationExecutor.swift | 6 ++++ .../OSSubscriptionOperationExecutor.swift | 6 ++++ .../Source/Executors/OSUserExecutor.swift | 6 ++++ .../Source/OSIdentityModelRepo.swift | 7 +++++ .../Source/OneSignalUserManagerImpl.swift | 6 ++++ iOS_SDK/OneSignalSDK/Source/OneSignal.m | 11 +++++++ 15 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSLoggable.swift diff --git a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift index eae4a119f..ddae6a8ec 100644 --- a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift +++ b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift @@ -32,5 +32,6 @@ class SwiftTest: NSObject { func testSwiftUserModel() { let token1 = OneSignal.User.pushSubscription.token let token = OneSignal.User.pushSubscription.token + OneSignal.Debug._dump() } } diff --git a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m index 9bcc2d37f..8a5f72eaf 100644 --- a/iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m +++ b/iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m @@ -133,6 +133,7 @@ - (IBAction)sendTagButton:(id)sender { - (IBAction)getTagsButton:(id)sender { NSDictionary *tags = [OneSignal.User getTags]; NSLog(@"Tags: %@", tags); + [OneSignal.Debug _dump]; } - (IBAction)sendTagsButton:(id)sender { diff --git a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj index 970382b96..210704586 100644 --- a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj +++ b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ 3C0151922C2E298F0079E076 /* OneSignalInAppMessages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEBAAE282A4211D900BF2C1C /* OneSignalInAppMessages.framework */; }; 3C01519C2C2E29F90079E076 /* IAMRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C01519B2C2E29F90079E076 /* IAMRequestTests.m */; }; 3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */; }; + 3C10E0632BF5651500A7B37F /* OSLoggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C10E0622BF5651500A7B37F /* OSLoggable.swift */; }; 3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */ = {isa = PBXBuildFile; fileRef = 3C115164289A259500565C41 /* OneSignalOSCore.docc */; }; 3C115171289A259500565C41 /* OneSignalOSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C115163289A259500565C41 /* OneSignalOSCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3C115185289ADE4F00565C41 /* OSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C115184289ADE4F00565C41 /* OSModel.swift */; }; @@ -1211,6 +1212,7 @@ 3C01518E2C2E298E0079E076 /* OneSignalInAppMessagesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OneSignalInAppMessagesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3C01519B2C2E29F90079E076 /* IAMRequestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IAMRequestTests.m; sourceTree = ""; }; 3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSUserInternalImpl.swift; sourceTree = ""; }; + 3C10E0622BF5651500A7B37F /* OSLoggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLoggable.swift; sourceTree = ""; }; 3C115161289A259500565C41 /* OneSignalOSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OneSignalOSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3C115163289A259500565C41 /* OneSignalOSCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalOSCore.h; sourceTree = ""; }; 3C115164289A259500565C41 /* OneSignalOSCore.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = OneSignalOSCore.docc; sourceTree = ""; }; @@ -2068,6 +2070,7 @@ 4710EA522B8FCFB200435356 /* OSDispatchQueue.swift */, DEFB3E642BB7346D00E65DAD /* OSLiveActivities.swift */, DEFB3E662BB735B500E65DAD /* OSStubLiveActivities.swift */, + 3C10E0622BF5651500A7B37F /* OSLoggable.swift */, ); path = Source; sourceTree = ""; @@ -4052,6 +4055,7 @@ DEFB3E652BB7346D00E65DAD /* OSLiveActivities.swift in Sources */, 3C4F9E4428A4466C009F453A /* OSOperationRepo.swift in Sources */, 3C11518B289ADEEB00565C41 /* OSEventProducer.swift in Sources */, + 3C10E0632BF5651500A7B37F /* OSLoggable.swift in Sources */, 3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */, 3C115189289ADEA300565C41 /* OSModelStore.swift in Sources */, 3C115185289ADE4F00565C41 /* OSModel.swift in Sources */, diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h index d5e72bcbe..a5e55c580 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h @@ -39,9 +39,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { @protocol OSDebug + (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel; + (void)setAlertLevel:(ONE_S_LOG_LEVEL)logLevel NS_REFINED_FOR_SWIFT; ++ (void)_dump; @end -@interface OneSignalLog : NSObject +@interface OneSignalLog : NSObject + (Class)Debug; + (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message; + (ONE_S_LOG_LEVEL)getLogLevel; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m index 0a840128b..231305209 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m @@ -29,6 +29,10 @@ #import "OneSignalLog.h" #import "OSDialogInstanceManager.h" +/** + Implements the Log Level methods of protocol `OSDebug`. + The `_dump` method will be implemented in OneSignal module. + */ @implementation OneSignalLog static ONE_S_LOG_LEVEL _nsLogLevel = ONE_S_LL_WARN; @@ -46,6 +50,8 @@ + (void)setAlertLevel:(ONE_S_LOG_LEVEL)logLevel { _alertLogLevel = logLevel; } ++ (void)_dump {} + + (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message { onesignal_Log(logLevel, message); } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSLoggable.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSLoggable.swift new file mode 100644 index 000000000..a82b34927 --- /dev/null +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSLoggable.swift @@ -0,0 +1,30 @@ +/* + Modified MIT License + + Copyright 2024 OneSignal + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + 1. The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + 2. All copies of substantial portions of the Software may only be used in connection + with services provided by OneSignal. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +public protocol OSLoggable { + func logSelf() +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift index 63c5e7a5d..6b1800075 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift @@ -30,7 +30,7 @@ import OneSignalCore /** Concrete executors drop OSDeltas and Requests when initializing from the cache, when they cannot be connected to their respective models anymore. These cannot be sent, so they are dropped.. */ -public protocol OSOperationExecutor { +public protocol OSOperationExecutor: OSLoggable { var supportedDeltas: [String] { get } var deltaQueue: [OSDelta] { get } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift index 338fadd50..a59a92ac7 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift @@ -173,3 +173,9 @@ public class OSOperationRepo: NSObject { } } } + +extension OSOperationRepo: OSLoggable { + public func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift index 6a7b44b4d..c6f7c468f 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift @@ -293,3 +293,9 @@ class OSIdentityOperationExecutor: OSOperationExecutor { } } } + +extension OSIdentityOperationExecutor: OSLoggable { + func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift index 5e1ea285c..377fa2bdc 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift @@ -288,3 +288,9 @@ class OSPropertyOperationExecutor: OSOperationExecutor { } } } + +extension OSPropertyOperationExecutor: OSLoggable { + func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift index 84b60ad3b..345fb1b04 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift @@ -421,3 +421,9 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor { } } } + +extension OSSubscriptionOperationExecutor: OSLoggable { + func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift index 43ad5b3d1..704150099 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift @@ -600,3 +600,9 @@ extension OSUserExecutor { return response?["identity"] as? [String: String] } } + +extension OSUserExecutor: OSLoggable { + func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift index 781fe4e8f..f59f94687 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift @@ -26,6 +26,7 @@ */ import Foundation +import OneSignalOSCore /** This class stores all Identity Models that are being used during an app session. @@ -53,3 +54,9 @@ class OSIdentityModelRepo { } } } + +extension OSIdentityModelRepo: OSLoggable { + func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift index 77ecd4c79..fde4f72f5 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift @@ -873,3 +873,9 @@ extension OneSignalUserManagerImpl: OneSignalNotificationsDelegate { user.pushSubscriptionModel.address = pushToken } } + +extension OneSignalUserManagerImpl: OSLoggable { + @objc public func logSelf() { + // TODO: You fill in + } +} diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index b18d5ffdc..e89177abd 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -77,6 +77,17 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" +/** + Implements the `_dump` method of protocol `OSDebug`. + */ +@implementation OneSignalLog (OSLoggable) ++ (void)_dump { + NSLog(@"💛 calling LOG!"); + [OneSignalUserManagerImpl.sharedInstance logSelf]; + // And more ... +} +@end + @interface OneSignal (SessionStatusDelegate) @end