Skip to content

Commit

Permalink
internal dump method helper
Browse files Browse the repository at this point in the history
* internal for now, put in information you want to log for each product that conforms to OSLoggable
  • Loading branch information
nan-li committed Aug 22, 2024
1 parent 529a148 commit 0ba7ad5
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 2 deletions.
1 change: 1 addition & 0 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ class SwiftTest: NSObject {
func testSwiftUserModel() {
let token1 = OneSignal.User.pushSubscription.token
let token = OneSignal.User.pushSubscription.token
OneSignal.Debug._dump()
}
}
1 change: 1 addition & 0 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ - (IBAction)sendTagButton:(id)sender {
- (IBAction)getTagsButton:(id)sender {
NSDictionary<NSString *, NSString*> *tags = [OneSignal.User getTags];
NSLog(@"Tags: %@", tags);
[OneSignal.Debug _dump];
}

- (IBAction)sendTagsButton:(id)sender {
Expand Down
4 changes: 4 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
3C0EF49D28A1DBCB00E5434B /* OSUserInternalImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSUserInternalImpl.swift; sourceTree = "<group>"; };
3C10E0622BF5651500A7B37F /* OSLoggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLoggable.swift; sourceTree = "<group>"; };
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 = "<group>"; };
3C115164289A259500565C41 /* OneSignalOSCore.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = OneSignalOSCore.docc; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2068,6 +2070,7 @@
4710EA522B8FCFB200435356 /* OSDispatchQueue.swift */,
DEFB3E642BB7346D00E65DAD /* OSLiveActivities.swift */,
DEFB3E662BB735B500E65DAD /* OSStubLiveActivities.swift */,
3C10E0622BF5651500A7B37F /* OSLoggable.swift */,
);
path = Source;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
3 changes: 2 additions & 1 deletion iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
@protocol OSDebug <NSObject>
+ (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel;
+ (void)setAlertLevel:(ONE_S_LOG_LEVEL)logLevel NS_REFINED_FOR_SWIFT;
+ (void)_dump;
@end

@interface OneSignalLog : NSObject<OSDebug>
@interface OneSignalLog : NSObject <OSDebug>
+ (Class<OSDebug>)Debug;
+ (void)onesignalLog:(ONE_S_LOG_LEVEL)logLevel message:(NSString* _Nonnull)message;
+ (ONE_S_LOG_LEVEL)getLogLevel;
Expand Down
6 changes: 6 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignalCore/Source/OneSignalLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
30 changes: 30 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSLoggable.swift
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,9 @@ public class OSOperationRepo: NSObject {
}
}
}

extension OSOperationRepo: OSLoggable {
public func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,9 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
}
}
}

extension OSIdentityOperationExecutor: OSLoggable {
func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,9 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
}
}
}

extension OSPropertyOperationExecutor: OSLoggable {
func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,9 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
}
}
}

extension OSSubscriptionOperationExecutor: OSLoggable {
func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,9 @@ extension OSUserExecutor {
return response?["identity"] as? [String: String]
}
}

extension OSUserExecutor: OSLoggable {
func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

import Foundation
import OneSignalOSCore

/**
This class stores all Identity Models that are being used during an app session.
Expand Down Expand Up @@ -53,3 +54,9 @@ class OSIdentityModelRepo {
}
}
}

extension OSIdentityModelRepo: OSLoggable {
func logSelf() {
// TODO: You fill in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,9 @@ extension OneSignalUserManagerImpl: OneSignalNotificationsDelegate {
user.pushSubscriptionModel.address = pushToken
}
}

extension OneSignalUserManagerImpl: OSLoggable {
@objc public func logSelf() {
// TODO: You fill in
}
}
11 changes: 11 additions & 0 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0ba7ad5

Please sign in to comment.