Skip to content

Commit

Permalink
Log name conflict and defaultClient nil fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Dec 22, 2015
1 parent 25dadef commit 003926b
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 28 deletions.
2 changes: 1 addition & 1 deletion OneSignal.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "OneSignal"
s.version = "1.10.5"
s.version = "1.10.6"
s.summary = "OneSignal push notification library for mobile apps."
s.homepage = "https://onesignal.com"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
Binary file added OneSignalExample/.DS_Store
Binary file not shown.
Binary file added iOS_SDK/.DS_Store
Binary file not shown.
Binary file modified iOS_SDK/Framework/OneSignal.framework/Versions/A/OneSignal
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<key>IDESourceControlProjectIdentifier</key>
<string>82DF9B41-8B65-40E7-832A-C61D19DFA081</string>
<key>IDESourceControlProjectName</key>
<string>OneSignal</string>
<string>project</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>5A4AFF41A71B5F8D4741699EC46766398BC4FE44</key>
<string>https://github.com/Hiptic/OneSignal</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>SDK/iOS/iOS_SDK/OneSignal.xcodeproj</string>
<string>SDK/iOS/iOS_SDK/OneSignal.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>5A4AFF41A71B5F8D4741699EC46766398BC4FE44</key>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3774802C19148A3700558FAD"
BuildableName = "OneSignal.Framework"
BlueprintName = "OneSignal.Framework"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3774802C19148A3700558FAD"
BuildableName = "OneSignal.Framework"
BlueprintName = "OneSignal.Framework"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3774802C19148A3700558FAD"
BuildableName = "OneSignal.Framework"
BlueprintName = "OneSignal.Framework"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37747F9219147D6500558FAD"
BuildableName = "libOneSignal.a"
BlueprintName = "OneSignal"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37747F9219147D6500558FAD"
BuildableName = "libOneSignal.a"
BlueprintName = "OneSignal"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37747F9219147D6500558FAD"
BuildableName = "libOneSignal.a"
BlueprintName = "OneSignal"
ReferencedContainer = "container:OneSignal.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>OneSignal.Framework.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>OneSignal.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>37747F9219147D6500558FAD</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>3774802C19148A3700558FAD</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
53 changes: 28 additions & 25 deletions iOS_SDK/OneSignal/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ @interface OneSignal ()

@implementation OneSignal

NSString* const ONESIGNAL_VERSION = @"011001";
NSString* const ONESIGNAL_VERSION = @"011006";

@synthesize app_id = _GT_publicKey;
@synthesize httpClient = _GT_httpRequest;
Expand Down Expand Up @@ -117,12 +117,12 @@ - (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
return self;

if (![[NSUUID alloc] initWithUUIDString:appId]) {
Log(ONE_S_LL_FATAL, @"OneSignal AppId format is invalid.\nExample: 'b2f7f966-d8cc-11eg-bed1-df8f05be55ba'\n");
onesignal_Log(ONE_S_LL_FATAL, @"OneSignal AppId format is invalid.\nExample: 'b2f7f966-d8cc-11eg-bed1-df8f05be55ba'\n");
return self;
}

if ([@"b2f7f966-d8cc-11eg-bed1-df8f05be55ba" isEqualToString:appId] || [@"5eb5a37e-b458-11e3-ac11-000c2940e62c" isEqualToString:appId])
Log(ONE_S_LL_WARN, @"OneSignal Example AppID detected, please update to your app's id found on OneSignal.com");
onesignal_Log(ONE_S_LL_WARN, @"OneSignal Example AppID detected, please update to your app's id found on OneSignal.com");


if (self) {
Expand Down Expand Up @@ -200,7 +200,7 @@ + (void)setLogLevel:(ONE_S_LOG_LEVEL)nsLogLevel visualLevel:(ONE_S_LOG_LEVEL)vis
_nsLogLevel = nsLogLevel; _visualLogLevel = visualLogLevel;
}

void Log(ONE_S_LOG_LEVEL logLevel, NSString* message) {
void onesignal_Log(ONE_S_LOG_LEVEL logLevel, NSString* message) {
NSString* levelString;
switch (logLevel) {
case ONE_S_LL_FATAL:
Expand Down Expand Up @@ -307,7 +307,7 @@ - (void)updateDeviceToken:(NSString*)deviceToken onSuccess:(OneSignalResultSucce
deviceToken, @"identifier",
nil];

Log(ONE_S_LL_VERBOSE, @"Calling OneSignal PUT updated pushToken!");
onesignal_Log(ONE_S_LL_VERBOSE, @"Calling OneSignal PUT updated pushToken!");
NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil];
[request setHTTPBody:postData];

Expand Down Expand Up @@ -405,7 +405,7 @@ - (void)registerUser {
if (releaseMode == UIApplicationReleaseDev || releaseMode == UIApplicationReleaseAdHoc)
dataDic[@"test_type"] = [NSNumber numberWithInt:releaseMode];

Log(ONE_S_LL_VERBOSE, @"Calling OneSignal create/on_session");
onesignal_Log(ONE_S_LL_VERBOSE, @"Calling OneSignal create/on_session");
NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil];
[request setHTTPBody:postData];

Expand Down Expand Up @@ -435,7 +435,7 @@ - (void)registerUser {
} onFailure:^(NSError* error) {
oneSignalReg = false;
waitingForOneSReg = false;
Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error registering with OneSignal: %@", error]);
onesignal_Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error registering with OneSignal: %@", error]);
}];
}

Expand All @@ -461,8 +461,8 @@ - (void)sendTagsWithJsonString:(NSString*)jsonString {
if (jsonError == nil)
[self sendTags:keyValuePairs];
else {
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"sendTags JSON Parse Error: %@", jsonError]);
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"sendTags JSON Parse Error, JSON: %@", jsonString]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"sendTags JSON Parse Error: %@", jsonError]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"sendTags JSON Parse Error, JSON: %@", jsonString]);
}
}

Expand Down Expand Up @@ -566,8 +566,8 @@ - (void)deleteTagsWithJsonString:(NSString*)jsonString {
if (jsonError == nil)
[self deleteTags:keys];
else {
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"deleteTags JSON Parse Error: %@", jsonError]);
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"deleteTags JSON Parse Error, JSON: %@", jsonString]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"deleteTags JSON Parse Error: %@", jsonError]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"deleteTags JSON Parse Error, JSON: %@", jsonString]);
}
}

Expand Down Expand Up @@ -887,13 +887,13 @@ - (void)postNotification:(NSDictionary*)jsonData onSuccess:(OneSignalResultSucce
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:results options:0 error:nil];
NSString* jsonResultsString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

Log(ONE_S_LL_DEBUG, [NSString stringWithFormat: @"HTTP create notification success %@", jsonResultsString]);
onesignal_Log(ONE_S_LL_DEBUG, [NSString stringWithFormat: @"HTTP create notification success %@", jsonResultsString]);
if (successBlock)
successBlock(results);
}
onFailure:^(NSError* error) {
Log(ONE_S_LL_ERROR, @"Create notification failed");
Log(ONE_S_LL_INFO, [NSString stringWithFormat: @"%@", error]);
onesignal_Log(ONE_S_LL_ERROR, @"Create notification failed");
onesignal_Log(ONE_S_LL_INFO, [NSString stringWithFormat: @"%@", error]);
if (failureBlock)
failureBlock(error);
}];
Expand All @@ -907,8 +907,8 @@ - (void)postNotificationWithJsonString:(NSString*)jsonString onSuccess:(OneSigna
if (jsonError == nil)
[self postNotification:jsonData onSuccess:successBlock onFailure:failureBlock];
else {
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"postNotification JSON Parse Error: %@", jsonError]);
Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"postNotification JSON Parse Error, JSON: %@", jsonString]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"postNotification JSON Parse Error: %@", jsonError]);
onesignal_Log(ONE_S_LL_WARN,[NSString stringWithFormat: @"postNotification JSON Parse Error, JSON: %@", jsonString]);
}
}

Expand Down Expand Up @@ -1004,11 +1004,11 @@ - (void)setSubscription:(BOOL)enable {
- (void)didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken {
NSString* trimmedDeviceToken = [[inDeviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
NSString* parsedDeviceToken = [[trimmedDeviceToken componentsSeparatedByString:@" "] componentsJoinedByString:@""];
Log((ONE_S_LOG_LEVEL)ONE_S_LL_INFO, [NSString stringWithFormat:@"Device Registered with Apple: %@", parsedDeviceToken]);
onesignal_Log((ONE_S_LOG_LEVEL)ONE_S_LL_INFO, [NSString stringWithFormat:@"Device Registered with Apple: %@", parsedDeviceToken]);
[self registerDeviceToken:parsedDeviceToken onSuccess:^(NSDictionary* results) {
Log(ONE_S_LL_INFO, [NSString stringWithFormat: @"Device Registered with OneSignal: %@", mUserId]);
onesignal_Log(ONE_S_LL_INFO, [NSString stringWithFormat: @"Device Registered with OneSignal: %@", mUserId]);
} onFailure:^(NSError* error) {
Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error in OneSignal Registration: %@", error]);
onesignal_Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error in OneSignal Registration: %@", error]);
}];
}

Expand Down Expand Up @@ -1176,14 +1176,15 @@ static void injectSelector(Class newClass, SEL newSel, Class addToClass, SEL mak
@implementation UIApplication(OneSignalPush)

- (void)oneSignalDidRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken {
[[OneSignal defaultClient] didRegisterForRemoteNotifications:app deviceToken:inDeviceToken];
if ([OneSignal defaultClient])
[[OneSignal defaultClient] didRegisterForRemoteNotifications:app deviceToken:inDeviceToken];

if ([self respondsToSelector:@selector(oneSignalDidRegisterForRemoteNotifications:deviceToken:)])
[self oneSignalDidRegisterForRemoteNotifications:app deviceToken:inDeviceToken];
}

- (void)oneSignalDidFailRegisterForRemoteNotification:(UIApplication*)app error:(NSError*)err {
Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error registering for Apple push notifications. Error: %@", err]);
onesignal_Log(ONE_S_LL_ERROR, [NSString stringWithFormat: @"Error registering for Apple push notifications. Error: %@", err]);

if ([self respondsToSelector:@selector(oneSignalDidFailRegisterForRemoteNotification:error:)])
[self oneSignalDidFailRegisterForRemoteNotification:app error:err];
Expand All @@ -1200,16 +1201,17 @@ - (void)oneSignalDidRegisterUserNotifications:(UIApplication*)application settin

// Notification opened! iOS 6 ONLY!
- (void)oneSignalReceivedRemoteNotification:(UIApplication*)application userInfo:(NSDictionary*)userInfo {
[[OneSignal defaultClient] notificationOpened:userInfo isActive:[application applicationState] == UIApplicationStateActive];
if ([OneSignal defaultClient])
[[OneSignal defaultClient] notificationOpened:userInfo isActive:[application applicationState] == UIApplicationStateActive];

if ([self respondsToSelector:@selector(oneSignalReceivedRemoteNotification:userInfo:)])
[self oneSignalReceivedRemoteNotification:application userInfo:userInfo];
}

// Notification opened or silent one received on iOS 7 & 8
- (void) oneSignalRemoteSilentNotification:(UIApplication*)application UserInfo:(NSDictionary*)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult)) completionHandler {

[[OneSignal defaultClient] remoteSilentNotification:application UserInfo:userInfo];
if ([OneSignal defaultClient])
[[OneSignal defaultClient] remoteSilentNotification:application UserInfo:userInfo];


if ([self respondsToSelector:@selector(oneSignalRemoteSilentNotification:UserInfo:fetchCompletionHandler:)])
Expand All @@ -1229,7 +1231,8 @@ - (void) oneSignalLocalNotificationOpened:(UIApplication*)application handleActi
}

- (void)oneSignalLocalNotificaionOpened:(UIApplication*)application notification:(UILocalNotification*)notification {
[[OneSignal defaultClient] processLocalActionBasedNotification:notification identifier:@"__DEFAULT__"];
if ([OneSignal defaultClient])
[[OneSignal defaultClient] processLocalActionBasedNotification:notification identifier:@"__DEFAULT__"];

if ([self respondsToSelector:@selector(oneSignalLocalNotificaionOpened:notification:)])
[self oneSignalLocalNotificaionOpened:application notification:notification];
Expand Down

0 comments on commit 003926b

Please sign in to comment.