Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DEF5CCF02539321A0003E9CC"
BuildableName = "UnitTestApp.app"
BlueprintName = "UnitTestApp"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "911E2CB91E398AB3003112A4"
BuildableName = "UnitTests.xctest"
BlueprintName = "UnitTests"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DEF5CCF02539321A0003E9CC"
BuildableName = "UnitTestApp.app"
BlueprintName = "UnitTestApp"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DEF5CCF02539321A0003E9CC"
BuildableName = "UnitTestApp.app"
BlueprintName = "UnitTestApp"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OSChannelTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ THE SOFTWARE.

@interface OSChannelTracker : NSObject

@property (nonatomic, readwrite) Session influenceType;
@property (nonatomic, readwrite) OSSession influenceType;
@property (strong, nonatomic, readwrite, nullable) NSString *directId;
@property (strong, nonatomic, readwrite, nullable) NSArray *indirectIds;
@property (strong, nonatomic, readonly, nonnull) OSInfluenceDataRepository *dataRepository;
Expand Down
10 changes: 5 additions & 5 deletions iOS_SDK/OneSignalSDK/Source/OSIndirectInfluence.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
Modified MIT License

Copyright 2019 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
Expand Down
4 changes: 2 additions & 2 deletions iOS_SDK/OneSignalSDK/Source/OSInfluence.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ THE SOFTWARE.
@interface OSInfluenceBuilder : NSObject

@property (nonatomic) OSInfluenceChannel influenceChannel;
@property (nonatomic) Session influenceType;
@property (nonatomic) OSSession influenceType;
@property (nonatomic, copy) NSArray * _Nullable ids;

@end

@interface OSInfluence : NSObject

@property (nonatomic, readonly) OSInfluenceChannel influenceChannel;
@property (nonatomic, readonly) Session influenceType;
@property (nonatomic, readonly) OSSession influenceType;
@property (nonatomic, readwrite) NSArray * _Nullable ids;

- (id _Nonnull)initWithBuilder:(OSInfluenceBuilder * _Nonnull)builder;
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OSInfluence.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (instancetype)init

@implementation OSInfluence

- (id)initWithInfluenceType:(Session)influenceType
- (id)initWithInfluenceType:(OSSession)influenceType
forInfluenceChannel:(OSInfluenceChannel)influenceChannel
withIds:(NSArray *)ids {
if (self = [super init]) {
Expand Down
8 changes: 4 additions & 4 deletions iOS_SDK/OneSignalSDK/Source/OSInfluenceDataRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ THE SOFTWARE.

@interface OSInfluenceDataRepository : NSObject

- (void)cacheNotificationInfluenceType:(Session) influenceType;
- (Session)notificationCachedInfluenceType;
- (void)cacheNotificationInfluenceType:(OSSession) influenceType;
- (OSSession)notificationCachedInfluenceType;

- (void)cacheIAMInfluenceType:(Session) influenceType;
- (Session)iamCachedInfluenceType;
- (void)cacheIAMInfluenceType:(OSSession) influenceType;
- (OSSession)iamCachedInfluenceType;

- (void)cacheNotificationOpenId:(NSString * _Nullable)notificationId;
- (NSString * _Nullable)cachedNotificationOpenId;
Expand Down
8 changes: 4 additions & 4 deletions iOS_SDK/OneSignalSDK/Source/OSInfluenceDataRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ of this software and associated documentation files (the "Software"), to deal

@implementation OSInfluenceDataRepository

- (void)cacheNotificationInfluenceType:(Session) influenceType {
- (void)cacheNotificationInfluenceType:(OSSession) influenceType {
[OneSignalUserDefaults.initShared saveStringForKey:OSUD_CACHED_NOTIFICATION_INFLUENCE withValue:OS_INFLUENCE_TYPE_TO_STRING(influenceType)];
}

- (Session)notificationCachedInfluenceType {
- (OSSession)notificationCachedInfluenceType {
NSString *sessionString = [OneSignalUserDefaults.initShared getSavedStringForKey:OSUD_CACHED_NOTIFICATION_INFLUENCE defaultValue:OS_INFLUENCE_TYPE_TO_STRING(UNATTRIBUTED)];
return OS_INFLUENCE_TYPE_FROM_STRING(sessionString);
}

- (void)cacheIAMInfluenceType:(Session) influenceType {
- (void)cacheIAMInfluenceType:(OSSession) influenceType {
[OneSignalUserDefaults.initShared saveStringForKey:OSUD_CACHED_IAM_INFLUENCE withValue:OS_INFLUENCE_TYPE_TO_STRING(influenceType)];
}

- (Session)iamCachedInfluenceType {
- (OSSession)iamCachedInfluenceType {
NSString *sessionString = [OneSignalUserDefaults.initShared getSavedStringForKey:OSUD_CACHED_IAM_INFLUENCE defaultValue:OS_INFLUENCE_TYPE_TO_STRING(UNATTRIBUTED)];
return OS_INFLUENCE_TYPE_FROM_STRING(sessionString);
}
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OSNotificationTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ - (void)saveChannelObjects:(NSArray * _Nonnull)channelObjects {
}

- (void)initInfluencedTypeFromCache {
Session influenceType = [self.dataRepository notificationCachedInfluenceType];
OSSession influenceType = [self.dataRepository notificationCachedInfluenceType];
self.influenceType = influenceType;

if (influenceType == INDIRECT)
Expand Down
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalSDK/Source/OSOutcomeEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

@interface OSOutcomeEvent () <OSJSONEncodable>

- (id _Nonnull)initWithSession:(Session)session
- (id _Nonnull)initWithSession:(OSSession)session
notificationIds:(NSArray * _Nullable)notificationIds
name:(NSString * _Nonnull)name
timestamp:(NSNumber * _Nonnull)timestamp
Expand Down
8 changes: 4 additions & 4 deletions iOS_SDK/OneSignalSDK/Source/OSOutcomeEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal

@implementation OSOutcomeEvent

- (id _Nonnull)initWithSession:(Session)influenceType
- (id _Nonnull)initWithSession:(OSSession)influenceType
notificationIds:(NSArray * _Nullable)notificationIds
name:(NSString * _Nonnull)name
timestamp:(NSNumber * _Nonnull)timestamp
Expand All @@ -50,9 +50,9 @@ - (id _Nonnull)initWithSession:(Session)influenceType
- (id)initFromOutcomeEventParams:(OSOutcomeEventParams *)outcomeEventParams {
if (self = [super init]) {
OSOutcomeSource *source = outcomeEventParams.outcomeSource;
Session influenceType = UNATTRIBUTED;
OSSession influenceType = UNATTRIBUTED;
NSArray *notificationId = nil;

if (source) {
if (source.directBody && source.directBody.notificationIds && source.directBody.notificationIds.count > 0) {
influenceType = DIRECT;
Expand All @@ -62,7 +62,7 @@ - (id)initFromOutcomeEventParams:(OSOutcomeEventParams *)outcomeEventParams {
notificationId = source.indirectBody.notificationIds;
}
}

_session = influenceType;
_notificationIds = notificationId;
_name = outcomeEventParams.outcomeId;
Expand Down
4 changes: 2 additions & 2 deletions iOS_SDK/OneSignalSDK/Source/OSSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ - (void)attemptSessionUpgrade:(AppEntryAction)entryAction withDirectId:(NSString
/*
Called when the session for the app changes, caches the state, and broadcasts the session that just ended
*/
- (BOOL)setSessionForChannel:(OSChannelTracker *)channelTracker withInfluenceType:(Session)influenceType directId:(NSString *)directId indirectIds:(NSArray *)indirectIds {
- (BOOL)setSessionForChannel:(OSChannelTracker *)channelTracker withInfluenceType:(OSSession)influenceType directId:(NSString *)directId indirectIds:(NSArray *)indirectIds {
if (![self willChangeSessionForChannel:channelTracker withInfluenceType:influenceType directId:directId indirectIds:indirectIds])
return NO;

Expand Down Expand Up @@ -226,7 +226,7 @@ - (BOOL)setSessionForChannel:(OSChannelTracker *)channelTracker withInfluenceTyp
2. Is DIRECT session data different from incoming DIRECT session data?
3. Is INDIRECT session data different from incoming INDIRECT session data?
*/
- (BOOL)willChangeSessionForChannel:(OSChannelTracker *)channelTracker withInfluenceType:(Session)influenceType directId:(NSString *)directId indirectIds:(NSArray *)indirectIds {
- (BOOL)willChangeSessionForChannel:(OSChannelTracker *)channelTracker withInfluenceType:(OSSession)influenceType directId:(NSString *)directId indirectIds:(NSArray *)indirectIds {
if (channelTracker.influenceType != influenceType)
return true;

Expand Down
4 changes: 2 additions & 2 deletions iOS_SDK/OneSignalSDK/Source/OneSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationActionType) {
// Pass in nil means a notification will not display
typedef void (^OSNotificationDisplayResponse)(OSNotification* _Nullable notification);
/* OneSignal Influence Types */
typedef NS_ENUM(NSUInteger, Session) {
typedef NS_ENUM(NSUInteger, OSSession) {
DIRECT,
INDIRECT,
UNATTRIBUTED,
Expand All @@ -225,7 +225,7 @@ typedef NS_ENUM(NSUInteger, OSInfluenceChannel) {
@interface OSOutcomeEvent : NSObject

// Session enum (DIRECT, INDIRECT, UNATTRIBUTED, or DISABLED) to determine code route and request params
@property (nonatomic) Session session;
@property (nonatomic) OSSession session;

// Notification ids for the current session
@property (strong, nonatomic, nullable) NSArray *notificationIds;
Expand Down
1 change: 1 addition & 0 deletions iOS_SDK/OneSignalSDK/Source/OneSignalSelectorHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ Class getClassWithProtocolInHierarchy(Class searchClass, Protocol* protocolToFin
NSArray* ClassGetSubclasses(Class parentClass);
void injectToProperClass(SEL newSel, SEL makeLikeSel, NSArray* delegateSubclasses, Class myClass, Class delegateClass);
BOOL injectSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel);
BOOL injectClassSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel);

#endif /* OneSignalSelectorHelpers_h */
21 changes: 21 additions & 0 deletions iOS_SDK/OneSignalSDK/Source/OneSignalSelectorHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ Class getClassWithProtocolInHierarchy(Class searchClass, Protocol* protocolToFin
return searchClass;
}

BOOL injectClassSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel) {
Method newMeth = class_getClassMethod(newClass, newSel);
IMP imp = method_getImplementation(newMeth);

const char* methodTypeEncoding = method_getTypeEncoding(newMeth);

BOOL existing = class_getClassMethod(addToClass, makeLikeSel) != NULL;

if (existing) {
class_addMethod(addToClass, newSel, imp, methodTypeEncoding);
newMeth = class_getClassMethod(addToClass, newSel);
// Method orgMeth = class_getClassMethod(addToClass, makeLikeSel);
class_replaceMethod(addToClass, makeLikeSel, imp, methodTypeEncoding);
//method_exchangeImplementations(orgMeth, newMeth);
}
else
class_addMethod(addToClass, makeLikeSel, imp, methodTypeEncoding);

return existing;
}

BOOL injectSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel) {
Method newMeth = class_getInstanceMethod(newClass, newSel);
IMP imp = method_getImplementation(newMeth);
Expand Down
34 changes: 34 additions & 0 deletions iOS_SDK/OneSignalSDK/UnitTestApp/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Modified MIT License
*
* Copyright 2020 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.
*/

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property UIWindow *window;

@end

41 changes: 41 additions & 0 deletions iOS_SDK/OneSignalSDK/UnitTestApp/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Modified MIT License
*
* Copyright 2020 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.
*/
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}

@end
Loading