From 9aac81b54639c2f1e07dfd558d90199bb95a8425 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Wed, 21 Jul 2021 18:35:36 -0700 Subject: [PATCH 1/3] rm push registration string 3000 error parsing * It is not reliable to use a string check on an error message to map to a specific OneSignal error code. * Second there is only one reason you would get a 3000 error code, the push notification capability is not enabled. - The 3000 "other" error that was being reported was never a thing. - This "other" 3000 error happens when the device is not set to English. - Also recently (iOS 13 or 14) the English error message changed. * This means we will no longer see the confusing "Other Apns 3000 Error" message on the OneSignal dashboard and will now see the correct "Missing Push Capability". --- iOS_SDK/OneSignalSDK/Source/OneSignal.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index 4567cd506..7968c7114 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -1603,15 +1603,9 @@ + (void)handleDidFailRegisterForRemoteNotification:(NSError*)err { waitingForApnsResponse = false; if (err.code == 3000) { - if ([((NSString*)[err.userInfo objectForKey:NSLocalizedDescriptionKey]) rangeOfString:@"no valid 'aps-environment'"].location != NSNotFound) { - // User did not enable push notification capability - [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_CAPABLILITY_DISABLED]; - [OneSignal onesignal_Log:ONE_S_LL_ERROR message:@"ERROR! 'Push Notification' capability not turned on! Enable it in Xcode under 'Project Target' -> Capability."]; - } - else { - [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_OTHER_3000_ERROR]; - [OneSignal onesignal_Log:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"ERROR! Unknown 3000 error returned from APNs when getting a push token: %@", err]]; - } + // User did not enable push notification capability + [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_CAPABLILITY_DISABLED]; + [OneSignal onesignal_Log:ONE_S_LL_ERROR message:@"ERROR! 'Push Notification' capability not turned on! Enable it in Xcode under 'Project Target' -> Capability."]; } else if (err.code == 3010) { [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_SIMULATOR_NOT_SUPPORTED]; From 4b7d046bea2c48441825327886b3e8835b6a88cb Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Wed, 21 Jul 2021 18:38:04 -0700 Subject: [PATCH 2/3] Mark ERROR_PUSH_OTHER_3000 as unused * Per the last commit we no longer will be using "other 3000" and instead this will always be ERROR_PUSH_CAPABLILITY_DISABLED instead. * Keeping the define but post-fixing with "_UNUSED_RESERVED" - This is so we don't reuse this notification_types value later and keep this around so someone can git-blame to find this reasoning. --- iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h b/iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h index 9cf7500f0..6ac5d9737 100644 --- a/iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h +++ b/iOS_SDK/OneSignalSDK/Source/OneSignalCommonDefines.h @@ -221,7 +221,7 @@ typedef enum {GET, POST, HEAD, PUT, DELETE, OPTIONS, CONNECT, TRACE} HTTPMethod; #define ERROR_PUSH_DELEGATE_NEVER_FIRED -14 #define ERROR_PUSH_SIMULATOR_NOT_SUPPORTED -15 #define ERROR_PUSH_UNKNOWN_APNS_ERROR -16 -#define ERROR_PUSH_OTHER_3000_ERROR -17 +#define ERROR_PUSH_OTHER_3000_ERROR_UNUSED_RESERVED -17 #define ERROR_PUSH_NEVER_PROMPTED -18 #define ERROR_PUSH_PROMPT_NEVER_ANSWERED -19 From 8119ee90487ce47ba0bdb16b7897c8fcfa014058 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Wed, 21 Jul 2021 18:57:43 -0700 Subject: [PATCH 3/3] Updated missing push notif capability error msg * Updated it with new instructions based what was observed in Xcode 12.4 --- iOS_SDK/OneSignalSDK/Source/OneSignal.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index 7968c7114..cca2255cf 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -1603,9 +1603,8 @@ + (void)handleDidFailRegisterForRemoteNotification:(NSError*)err { waitingForApnsResponse = false; if (err.code == 3000) { - // User did not enable push notification capability [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_CAPABLILITY_DISABLED]; - [OneSignal onesignal_Log:ONE_S_LL_ERROR message:@"ERROR! 'Push Notification' capability not turned on! Enable it in Xcode under 'Project Target' -> Capability."]; + [OneSignal onesignal_Log:ONE_S_LL_ERROR message:@"ERROR! 'Push Notifications' capability missing! Add the capability in Xcode under 'Target' -> '' -> 'Signing & Capabilities' then click the '+ Capability' button."]; } else if (err.code == 3010) { [OneSignal setSubscriptionErrorStatus:ERROR_PUSH_SIMULATOR_NOT_SUPPORTED];