Skip to content

Commit

Permalink
Added plist option to disable badge clearing and setEmail method
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Apr 1, 2016
1 parent 159903a commit e5696d4
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 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.12.2"
s.version = "1.13.0"
s.summary = "OneSignal push notification library for mobile apps."
s.homepage = "https://onesignal.com"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
Binary file removed iOS_SDK/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
- (void)sendTags:(NSDictionary*)keyValuePair;
- (void)sendTagsWithJsonString:(NSString*)jsonString;

- (void)setEmail:(NSString*)email;

- (void)getTags:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock;
- (void)getTags:(OneSignalResultSuccessBlock)successBlock;

Expand Down
Binary file modified iOS_SDK/Framework/OneSignal.framework/Versions/A/OneSignal
Binary file not shown.
4 changes: 2 additions & 2 deletions iOS_SDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -330,7 +330,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
SDKROOT = iphoneos;
Expand Down
2 changes: 2 additions & 0 deletions iOS_SDK/OneSignal/OneSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
- (void)sendTags:(NSDictionary*)keyValuePair;
- (void)sendTagsWithJsonString:(NSString*)jsonString;

- (void)setEmail:(NSString*)email;

- (void)getTags:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock;
- (void)getTags:(OneSignalResultSuccessBlock)successBlock;

Expand Down
43 changes: 41 additions & 2 deletions iOS_SDK/OneSignal/OneSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ @interface OneSignal ()

@implementation OneSignal

NSString* const ONESIGNAL_VERSION = @"011202";
NSString* const ONESIGNAL_VERSION = @"011300";

@synthesize app_id = _GT_publicKey;
@synthesize httpClient = _GT_httpRequest;
@synthesize lastMessageReceived;

bool disableBadgeClearing = false;

NSMutableDictionary* tagsToSend;
NSString* emailToSet;

NSString* mDeviceToken;
OneSignalResultSuccessBlock tokenUpdateSuccessBlock;
Expand Down Expand Up @@ -166,6 +169,8 @@ - (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId
self.app_id = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GameThrive_APPID"];
}

disableBadgeClearing = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"OneSignal_disable_badge_clearing"];


NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", DEFAULT_PUSH_HOST]];
self.httpClient = [[OneSignalHTTPClient alloc] initWithBaseURL:url];
Expand Down Expand Up @@ -469,6 +474,12 @@ - (void)registerUser {
lastLocation = nil;
}

if (emailToSet) {
[self setEmail:emailToSet];
emailToSet = nil;

}

if (idsAvailableBlockWhenReady) {
idsAvailableBlockWhenReady(mUserId, getUsableDeviceToken());
if (getUsableDeviceToken())
Expand Down Expand Up @@ -549,6 +560,34 @@ - (void)sendTag:(NSString*)key value:(NSString*)value onSuccess:(OneSignalResult
[self sendTags:[NSDictionary dictionaryWithObjectsAndKeys: value, key, nil] onSuccess:successBlock onFailure:failureBlock];
}


- (void)setEmail:(NSString*)email {
if (NSFoundationVersionNumber < NSFoundationVersionNumber_iOS_6_0 || mUserId == nil)
return;

if (mUserId == nil) {
emailToSet = email;
return;
}

NSMutableURLRequest* request = [self.httpClient requestWithMethod:@"PUT" path:[NSString stringWithFormat:@"players/%@", mUserId]];

NSDictionary* dataDic = [NSDictionary dictionaryWithObjectsAndKeys:
self.app_id, @"app_id",
email, @"email",
getNetType(), @"net_type",
nil];

NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil];
[request setHTTPBody:postData];

[self enqueueRequest:request
onSuccess:nil
onFailure:nil];


}

- (void)getTags:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock {
if (NSFoundationVersionNumber < NSFoundationVersionNumber_iOS_6_0 || mUserId == nil)
return;
Expand Down Expand Up @@ -839,7 +878,7 @@ - (void) handleNotificationOpened:(NSDictionary*)messageDict isActive:(BOOL)isAc
}

bool clearBadgeCount(bool fromNotifOpened) {
if (mNotificationTypes == -1 || (mNotificationTypes & NOTIFICATION_TYPE_BADGE) == 0)
if (disableBadgeClearing || mNotificationTypes == -1 || (mNotificationTypes & NOTIFICATION_TYPE_BADGE) == 0)
return false;

bool wasBadgeSet = [UIApplication sharedApplication].applicationIconBadgeNumber > 0;
Expand Down
1 change: 0 additions & 1 deletion iOS_SDK/OneSignal/OneSignalLocation.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ + (void) getLocation:(id)delegate prompt:(bool)prompt {
}

+ (void) internalGetLocation:(id)delegate prompt:(bool)prompt {
NSLog(@"getLocation called:started:%d", started);
if (started)
return;

Expand Down

0 comments on commit e5696d4

Please sign in to comment.