Skip to content

Commit 0ba7ad5

Browse files
committed
internal dump method helper
* internal for now, put in information you want to log for each product that conforms to OSLoggable
1 parent 529a148 commit 0ba7ad5

15 files changed

+99
-2
lines changed

iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ class SwiftTest: NSObject {
3232
func testSwiftUserModel() {
3333
let token1 = OneSignal.User.pushSubscription.token
3434
let token = OneSignal.User.pushSubscription.token
35+
OneSignal.Debug._dump()
3536
}
3637
}

iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ - (IBAction)sendTagButton:(id)sender {
133133
- (IBAction)getTagsButton:(id)sender {
134134
NSDictionary<NSString *, NSString*> *tags = [OneSignal.User getTags];
135135
NSLog(@"Tags: %@", tags);
136+
[OneSignal.Debug _dump];
136137
}
137138

138139
- (IBAction)sendTagsButton:(id)sender {

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
3C0151922C2E298F0079E076 /* OneSignalInAppMessages.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEBAAE282A4211D900BF2C1C /* OneSignalInAppMessages.framework */; };
5757
3C01519C2C2E29F90079E076 /* IAMRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C01519B2C2E29F90079E076 /* IAMRequestTests.m */; };
5858
3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */; };
59+
3C10E0632BF5651500A7B37F /* OSLoggable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C10E0622BF5651500A7B37F /* OSLoggable.swift */; };
5960
3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */ = {isa = PBXBuildFile; fileRef = 3C115164289A259500565C41 /* OneSignalOSCore.docc */; };
6061
3C115171289A259500565C41 /* OneSignalOSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C115163289A259500565C41 /* OneSignalOSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
6162
3C115185289ADE4F00565C41 /* OSModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C115184289ADE4F00565C41 /* OSModel.swift */; };
@@ -1211,6 +1212,7 @@
12111212
3C01518E2C2E298E0079E076 /* OneSignalInAppMessagesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OneSignalInAppMessagesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
12121213
3C01519B2C2E29F90079E076 /* IAMRequestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IAMRequestTests.m; sourceTree = "<group>"; };
12131214
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSUserInternalImpl.swift; sourceTree = "<group>"; };
1215+
3C10E0622BF5651500A7B37F /* OSLoggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLoggable.swift; sourceTree = "<group>"; };
12141216
3C115161289A259500565C41 /* OneSignalOSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OneSignalOSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
12151217
3C115163289A259500565C41 /* OneSignalOSCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalOSCore.h; sourceTree = "<group>"; };
12161218
3C115164289A259500565C41 /* OneSignalOSCore.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = OneSignalOSCore.docc; sourceTree = "<group>"; };
@@ -2068,6 +2070,7 @@
20682070
4710EA522B8FCFB200435356 /* OSDispatchQueue.swift */,
20692071
DEFB3E642BB7346D00E65DAD /* OSLiveActivities.swift */,
20702072
DEFB3E662BB735B500E65DAD /* OSStubLiveActivities.swift */,
2073+
3C10E0622BF5651500A7B37F /* OSLoggable.swift */,
20712074
);
20722075
path = Source;
20732076
sourceTree = "<group>";
@@ -4052,6 +4055,7 @@
40524055
DEFB3E652BB7346D00E65DAD /* OSLiveActivities.swift in Sources */,
40534056
3C4F9E4428A4466C009F453A /* OSOperationRepo.swift in Sources */,
40544057
3C11518B289ADEEB00565C41 /* OSEventProducer.swift in Sources */,
4058+
3C10E0632BF5651500A7B37F /* OSLoggable.swift in Sources */,
40554059
3C115165289A259500565C41 /* OneSignalOSCore.docc in Sources */,
40564060
3C115189289ADEA300565C41 /* OSModelStore.swift in Sources */,
40574061
3C115185289ADE4F00565C41 /* OSModel.swift in Sources */,

iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
3939
@protocol OSDebug <NSObject>
4040
+ (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel;
4141
+ (void)setAlertLevel:(ONE_S_LOG_LEVEL)logLevel NS_REFINED_FOR_SWIFT;
42+
+ (void)_dump;
4243
@end
4344

44-
@interface OneSignalLog : NSObject<OSDebug>
45+
@interface OneSignalLog : NSObject <OSDebug>
4546
+ (Class<OSDebug>)Debug;
4647
+ (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message;
4748
+ (ONE_S_LOG_LEVEL)getLogLevel;

iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
#import "OneSignalLog.h"
3030
#import "OSDialogInstanceManager.h"
3131

32+
/**
33+
Implements the Log Level methods of protocol `OSDebug`.
34+
The `_dump` method will be implemented in OneSignal module.
35+
*/
3236
@implementation OneSignalLog
3337

3438
static ONE_S_LOG_LEVEL _nsLogLevel = ONE_S_LL_WARN;
@@ -46,6 +50,8 @@ + (void)setAlertLevel:(ONE_S_LOG_LEVEL)logLevel {
4650
_alertLogLevel = logLevel;
4751
}
4852

53+
+ (void)_dump {}
54+
4955
+ (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message {
5056
onesignal_Log(logLevel, message);
5157
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Modified MIT License
3+
4+
Copyright 2024 OneSignal
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
1. The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
2. All copies of substantial portions of the Software may only be used in connection
17+
with services provided by OneSignal.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.
26+
*/
27+
28+
public protocol OSLoggable {
29+
func logSelf()
30+
}

iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import OneSignalCore
3030
/**
3131
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..
3232
*/
33-
public protocol OSOperationExecutor {
33+
public protocol OSOperationExecutor: OSLoggable {
3434
var supportedDeltas: [String] { get }
3535
var deltaQueue: [OSDelta] { get }
3636

iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationRepo.swift

+6
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,9 @@ public class OSOperationRepo: NSObject {
173173
}
174174
}
175175
}
176+
177+
extension OSOperationRepo: OSLoggable {
178+
public func logSelf() {
179+
// TODO: You fill in
180+
}
181+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift

+6
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,9 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
293293
}
294294
}
295295
}
296+
297+
extension OSIdentityOperationExecutor: OSLoggable {
298+
func logSelf() {
299+
// TODO: You fill in
300+
}
301+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift

+6
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,9 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
288288
}
289289
}
290290
}
291+
292+
extension OSPropertyOperationExecutor: OSLoggable {
293+
func logSelf() {
294+
// TODO: You fill in
295+
}
296+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift

+6
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,9 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
421421
}
422422
}
423423
}
424+
425+
extension OSSubscriptionOperationExecutor: OSLoggable {
426+
func logSelf() {
427+
// TODO: You fill in
428+
}
429+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift

+6
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,9 @@ extension OSUserExecutor {
600600
return response?["identity"] as? [String: String]
601601
}
602602
}
603+
604+
extension OSUserExecutor: OSLoggable {
605+
func logSelf() {
606+
// TODO: You fill in
607+
}
608+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
import Foundation
29+
import OneSignalOSCore
2930

3031
/**
3132
This class stores all Identity Models that are being used during an app session.
@@ -53,3 +54,9 @@ class OSIdentityModelRepo {
5354
}
5455
}
5556
}
57+
58+
extension OSIdentityModelRepo: OSLoggable {
59+
func logSelf() {
60+
// TODO: You fill in
61+
}
62+
}

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift

+6
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,9 @@ extension OneSignalUserManagerImpl: OneSignalNotificationsDelegate {
873873
user.pushSubscriptionModel.address = pushToken
874874
}
875875
}
876+
877+
extension OneSignalUserManagerImpl: OSLoggable {
878+
@objc public func logSelf() {
879+
// TODO: You fill in
880+
}
881+
}

iOS_SDK/OneSignalSDK/Source/OneSignal.m

+11
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@
7777
#pragma clang diagnostic push
7878
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
7979

80+
/**
81+
Implements the `_dump` method of protocol `OSDebug`.
82+
*/
83+
@implementation OneSignalLog (OSLoggable)
84+
+ (void)_dump {
85+
NSLog(@"💛 calling LOG!");
86+
[OneSignalUserManagerImpl.sharedInstance logSelf];
87+
// And more ...
88+
}
89+
@end
90+
8091
@interface OneSignal (SessionStatusDelegate)
8192
@end
8293

0 commit comments

Comments
 (0)