|
35 | 35 |
|
36 | 36 | #define DEFAULT_PUSH_HOST @"https://onesignal.com/api/v1/" |
37 | 37 |
|
38 | | -NSString* const VERSION = @"010901"; |
| 38 | +NSString* const VERSION = @"010902"; |
39 | 39 |
|
40 | 40 | #define NOTIFICATION_TYPE_BADGE 1 |
41 | 41 | #define NOTIFICATION_TYPE_SOUND 2 |
@@ -160,7 +160,10 @@ - (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId |
160 | 160 |
|
161 | 161 | mUserId = [defaults stringForKey:@"GT_PLAYER_ID"]; |
162 | 162 | mDeviceToken = [defaults stringForKey:@"GT_DEVICE_TOKEN"]; |
163 | | - registeredWithApple = mDeviceToken != nil || [defaults boolForKey:@"GT_REGISTERED_WITH_APPLE"]; |
| 163 | + if (([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)])) |
| 164 | + registeredWithApple = [[UIApplication sharedApplication] currentUserNotificationSettings].types != (NSUInteger)nil; |
| 165 | + else |
| 166 | + registeredWithApple = mDeviceToken != nil || [defaults boolForKey:@"GT_REGISTERED_WITH_APPLE"]; |
164 | 167 | mSubscriptionSet = [defaults objectForKey:@"ONESIGNAL_SUBSCRIPTION"] == nil; |
165 | 168 | mNotificationTypes = getNotificationTypes(); |
166 | 169 |
|
@@ -303,6 +306,7 @@ - (void)updateDeviceToken:(NSString*)deviceToken onSuccess:(OneSignalResultSucce |
303 | 306 | deviceToken, @"identifier", |
304 | 307 | nil]; |
305 | 308 |
|
| 309 | + Log(ONE_S_LL_VERBOSE, @"Calling OneSignal PUT updated pushToken!"); |
306 | 310 | NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil]; |
307 | 311 | [request setHTTPBody:postData]; |
308 | 312 |
|
@@ -398,6 +402,7 @@ - (void)registerUser { |
398 | 402 | if (releaseMode == UIApplicationReleaseDev || releaseMode == UIApplicationReleaseAdHoc) |
399 | 403 | dataDic[@"test_type"] = [NSNumber numberWithInt:releaseMode]; |
400 | 404 |
|
| 405 | + Log(ONE_S_LL_VERBOSE, @"Calling OneSignal create/on_session"); |
401 | 406 | NSData* postData = [NSJSONSerialization dataWithJSONObject:dataDic options:0 error:nil]; |
402 | 407 | [request setHTTPBody:postData]; |
403 | 408 |
|
@@ -982,7 +987,6 @@ - (void)setSubscription:(BOOL)enable { |
982 | 987 | [self sendNotificationTypesUpdateIsConfirmed:false]; |
983 | 988 | } |
984 | 989 |
|
985 | | - |
986 | 990 | - (void)didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken { |
987 | 991 | NSString* trimmedDeviceToken = [[inDeviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]; |
988 | 992 | NSString* parsedDeviceToken = [[trimmedDeviceToken componentsSeparatedByString:@" "] componentsJoinedByString:@""]; |
|
0 commit comments