Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on iOS 13 Beta #504

Closed
henning-cg opened this issue Jun 21, 2019 · 49 comments
Closed

Not working on iOS 13 Beta #504

henning-cg opened this issue Jun 21, 2019 · 49 comments

Comments

@henning-cg
Copy link

Description:

While trying our app on iOS 13 Beta 2, I noticed that OneSignal does not work. We are initializing the SDK in "didFinishLaunchingWithOptions", and after that the following log gets printed:

2019-06-21 12:57:28.039669+0200 OurApp[575:45514] ERROR: Encountered error during push registration with OneSignal: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
errors = (
"["Identifier invalid format."]"
);
success = 0;
}}
2019-06-21 12:57:28.039767+0200 OurApp[575:45514] ERROR: Encountered error during email registration with OneSignal: (null)
2019-06-21 12:57:57.759309+0200 OurApp[575:45514] ERROR: Encountered error during push registration with OneSignal: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
errors = (
"["Identifier invalid format."]"
);
success = 0;
}}

Environment

  1. iOS SDK 2.10.0
  2. Added via Carthage

Steps to Reproduce Issue:

  1. Install iOS SDK 2.10.0
  2. Init SDK in didFinishLaunchingWithOptions:
  3. In the log appear above error messages

Anything else:

The app does not crash, it simply does not register with OneSignal. Above log messages get repeated after some time, probably the SDK re-trying to register

@henning-cg
Copy link
Author

After turning on verbose logging for the OneSignal SDK, I've noticed the following difference:

On iOS 12.2, the following is sent in OSRequestRegisterUser:

...
"identifier": "5c868...............40cdb"
...

while on iOS 13 the following is sent:

...
"identifier": "{length=32,bytes=0x5c868...............40cdb}"
...

@animeshp
Copy link

I'm also having the same issue.

@rgomezp
Copy link
Contributor

rgomezp commented Jun 25, 2019

Thank you for bringing this up. Because iOS 13 is still in Beta, this issue may be resolved before the release this fall. However, we will keep a close eye on this leading up to the release. Thanks again

@henning-cg
Copy link
Author

According to https://forums.developer.apple.com/thread/117545, the issue might be caused by incorrectly using the [NSData description] method to convert the identifier to a String, and the correct way would be to format the bytes into the desired form, as explained in the example by vasyl.liutikov (or at the link he provides to facebook sdk: https://github.com/facebook/facebook-objc-sdk/blob/37bb3901a65d9f229171c25ed8db0297dc171f76/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKInternalUtility.m#L521 )

@rgomezp
Copy link
Contributor

rgomezp commented Jun 26, 2019

@henning-cg ,
Thanks for the details. We will look further into this in order to fix in a coming release.

@owenzhao
Copy link

Is that possible to show errors more obviously? For me, it took me for a long time until I found the error message on the console. Why not just crashing the app at least in Debug mode?

@owenzhao
Copy link

let trimmedDeviceToken = [[inDeviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];

line 2091 of OneSignal.m

probably here.

@canpoyrazoglu
Copy link

canpoyrazoglu commented Jul 10, 2019

Same here in iOS 13 Beta 3. In ids callback, payload has pushToken which goes like {length=32,...} instead of the bytes, probably causing everything to mess up and making userId null.

Since we, developers, are already testing for iOS 13 (that's why beta program is for), I think this needs to be addressed with high priority.

@mikepugh
Copy link

We're running into this as well and would appreciate a quick turnaround.

@canpoyrazoglu
Copy link

canpoyrazoglu commented Jul 11, 2019

Yup, @owenzhao is right. It's that line. I've made a temporary fix:

THIS IS A TEMPORARY FIX, USE ONLY UNTIL OFFICIAL LIBRARY IS UPDATED FOR iOS 13

ANY CHANGES DONE MAY BE PURGED WHEN PACKAGES FROM COCOAPODS/CARTHAGE/NPM/YARN ETC. ARE UPDATED


I've taken this answer and pasted somewhere at top into OneSignal.m (make sure to paste it in an empty place, not inside an @implementation or @interface block:

@implementation NSData (NSData_Conversion)

#pragma mark - String Conversion
- (NSString *)hexadecimalString {
    /* Returns hexadecimal string of NSData. Empty string if data is empty.   */

    const unsigned char *dataBuffer = (const unsigned char *)[self bytes];

    if (!dataBuffer)
        return [NSString string];

    NSUInteger          dataLength  = [self length];
    NSMutableString     *hexString  = [NSMutableString stringWithCapacity:(dataLength * 2)];

    for (int i = 0; i < dataLength; ++i)
        [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]];

    return [NSString stringWithString:hexString];
}

@end

Then, inside OneSignal class, change didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken method as follows:

+ (void)didRegisterForRemoteNotifications:(UIApplication*)app deviceToken:(NSData*)inDeviceToken {
    if ([OneSignal shouldLogMissingPrivacyConsentErrorWithMethodName:nil])
        return;
    
    let parsedDeviceToken = [inDeviceToken hexadecimalString];
    
    
    [OneSignal onesignal_Log:ONE_S_LL_INFO message: [NSString stringWithFormat:@"Device Registered with Apple: %@", [inDeviceToken hexadecimalString]]];
    
    waitingForApnsResponse = false;
    
    if (!app_id)
        return;
    
    [OneSignal updateDeviceToken:parsedDeviceToken onSuccess:^(NSDictionary* results) {
        [OneSignal onesignal_Log:ONE_S_LL_INFO message:[NSString stringWithFormat: @"Device Registered with OneSignal: %@", self.currentSubscriptionState.userId]];
    } onFailure:^(NSError* error) {
        [OneSignal onesignal_Log:ONE_S_LL_ERROR message:[NSString stringWithFormat: @"Error in OneSignal Registration: %@", error]];
    }];
}

If you're just referencing OneSignal as a subproject/side project you don't need to do anything, you're ready.

If you are statically linking or using a package manager (e.g. CocoaPods, Carthage, or yarn/npm if on React Native like me): Archive and export the library, find libOneSignal.a file in the output (tip: it's in node_modules for React Native), and replace it with yours, and voila, you've got OneSignal again.

I haven't tested this in pre-iOS 13 as I only have an iOS 13 device, but it should work. It works on iPhone X, iOS 13 Developer Beta 3 in my React Native app as of speaking (though it should work on regular iOS apps since I haven't touched React Native or React Native bridge project and I've only touched the native iOS project).

Again, use this for development until the library is officially updated, then go back to using the original library.

@janczakb
Copy link

@canpoyrazoglu do you know how to improve this for cocoapods?

@canpoyrazoglu
Copy link

@janczakb I haven't spent time for forking the repo and changing the dependencies as this is a temporary solution just for developer testing, so just open the project from the pods, change the code, build it, and it should work until you regenerate/reinstall the pods for whatever reason. To be sure you can check the last modified date of the pod library/framework for the OneSignal project.

@schenkty
Copy link

Just wanted to say that I am currently testing on beta 4 and the same issue exists.

@Alejandro99aru
Copy link

I have the same issue

@giogus
Copy link

giogus commented Jul 28, 2019

I'm having the same issue using the iOS 13 Beta 4.

@Nightsd01
Copy link
Contributor

I’ll create a PR for this tomorrow if no one beats me to the punch ;)

@rgomezp
Copy link
Contributor

rgomezp commented Jul 30, 2019

@Nightsd01 ,
Thanks!

@rgomezp rgomezp changed the title Not working on iOS 13 Beta 2 Not working on iOS 13 Beta Aug 2, 2019
@hawthornelove2016
Copy link

When will this be fixed for iOS 13 users?

@schenkty
Copy link

schenkty commented Aug 4, 2019

Wanted to jump back in here and say that I am using my app on iOS 13 and it seems to work fine-ish? There are still errors and such but I do register for notifications and can receive them which I did not expect. I'm currently on beta 5

@Nightsd01
Copy link
Contributor

Created a PR to fix this (#509)

@atilsamancioglu
Copy link

this is still not working on beta 5

@owenzhao
Copy link

owenzhao commented Aug 6, 2019

this is still not working on beta 5

As the PR has not been accepted. We need the new release on cocoapods.

@rgomezp rgomezp closed this as completed Aug 7, 2019
@SergeiMeza
Copy link

@jkasten2 When will the next build be released?

@jkasten2
Copy link
Member

jkasten2 commented Aug 9, 2019

We just released 2.10.1 with this fix.
https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/2.10.1

@NumaNumaNuma
Copy link

NumaNumaNuma commented Sep 6, 2019

@jkasten2 Did the fix make it into the Unity sdk as well? I'm still seeing the error with ios 13.1 beta 2 and xcode beta 7.

@rgomezp
Copy link
Contributor

rgomezp commented Sep 11, 2019

@NumaNumaNuma
Copy link

Ok thanks 👍

@trevinwisaksana
Copy link

trevinwisaksana commented Sep 27, 2019

I am still getting this error when using OneSignal iOS SDK version 2.11.1 on iOS 13.1. This may be caused by the Xcode 11 compiler.

Upon calling this code below:
OneSignal.getPermissionSubscriptionState().subscriptionStatus.userId
It is always returning an empty string even though I have given permission for push notification.

I am also getting this exact same error when I run it on iOS 13.1.

ERROR: Encountered error during push registration with OneSignal: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={ errors = ( "[\"Identifier invalid format.\"]" ); success = 0; }}

Am I missing something? Is there anything that I should update? At this time of writing OneSignal iOS SDK version 2.11.1 is the latest release.

@owenzhao
Copy link

owenzhao commented Sep 27, 2019 via email

@trevinwisaksana
Copy link

trevinwisaksana commented Sep 27, 2019

I tried it just now and it's still not working. The biggest different between what we did is I am using Xcode 11 and you're using Xcode 11.1 GM. Theoretically, this shouldn't affect it. But I guess this should be put to the test.

@owenzhao
Copy link

I tried it just now and it's still not working. The biggest different between what we did is I am using Xcode 11 and you're using Xcode 11.1 GM. Theoretically, this shouldn't affect it. But I guess this should be put to the test.

I don't think so. I had been using Xcode 11 betas, GM and GM 2 for quite a while. As Xcode 11.1 GM came suddenly without any prior betas two days ago.

I have not encounter this issue ever since " 2.10.1" released on Aug 2.

@trevinwisaksana
Copy link

I see. But what other issues could trigger this error message?

ERROR: Encountered error during push registration with OneSignal: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={ errors = ( "[\"Identifier invalid format.\"]" ); success = 0; }}

I ran the same code on iOS 12 and it works normally. But for iPad OS and iOS 13 it suddenly stops working.

@NumaNumaNuma
Copy link

NumaNumaNuma commented Sep 27, 2019 via email

@trevinwisaksana
Copy link

Thanks for bringing this up. After we tested it on Test Flight, it works! I don't know if it's just us but testing it by installing the app directly from Xcode doesn't work for devices using iOS 13.

But anyways, it solved our problem 😃

@NumaNumaNuma
Copy link

NumaNumaNuma commented Sep 27, 2019 via email

@Monte9
Copy link

Monte9 commented Oct 3, 2019

testing it by installing the app directly from Xcode doesn't work for devices using iOS 13.

Yup I ran into this issue as well. I don't see my device show up on the OneSignal dashboard.

@asccort
Copy link

asccort commented Oct 10, 2019

I was facing this same problem and was a iOS13 issue. (On iOS12 there is no problem)
The fix is simple and is update the onesignal iOS SDK to "onesignal-cordova-plugin": "^2.6.0",
if you are using ionic open a terminal window then go to your Ionic project folder then
cordova plugin remove onesignal-cordova-plugin
cordova plugin add onesignal-cordova-plugin

The version of the One signal iOS SDK on Xcode must appear '2.11.0'
(You can see this on Pods -> Podfile

@airman00
Copy link

airman00 commented Oct 15, 2019

For React Native 0.61.1

  1. Go to your project folder and upgrade module
    yarn upgrade react-native-onesignal

  2. Make sure its linked
    react-native link react-native-onesignal

  3. Go into the iOS folder and update your Pods
    cd ios
    pod update react-native-onesignal

@cristiancedenogallego
Copy link

cristiancedenogallego commented Oct 19, 2019

@asccort

After update cordova plugin version, should run
cd platform/ios && pod install to update pod dependency also is important clear build folder before
run or archive

@NupendraVerma
Copy link

Please replace your one signal pod version from pod 'OneSignal', '>= 2.6.2', '< 3.0' to pod 'OneSignal', '>= 2.11.2', '< 3.0'

@neowinston
Copy link

neowinston commented Nov 6, 2019

@NupendraVerma
Thanks, it's working.

@dklt
Copy link

dklt commented Nov 25, 2019

This is showing up in my debugger log,

UserInfo={returned={
    errors =     (
        "[\"Identifier invalid format.\"]"
    );
    success = 0;
}}

problem: I was version locked to 2.5.1.
fix: as suggested above
pod 'OneSignal', '>= 2.11.2', '< 3.0'

@priyankastridhyatech
Copy link

pod 'OneSignal', '>= 2.11.2', '< 3.0'

This is give me error like this

[!] Invalid Podfile file: syntax error, unexpected tIDENTIFIER, expecting end
// pod 'OneSignal'
^~~
: syntax error, unexpected end, expecting end-of-input.

@chaymankala
Copy link

I get this error in log, using onesignal 2.9.0,

ERROR: Encountered error during push registration with OneSignal: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={
    errors =     (
        "[\"Identifier invalid format.\"]"
    );
    success = 0;
}}

My podfile is this

pod 'OneSignal', '>= 2.11.2', '< 3.0'

@neowinston
Copy link

@priyankastridhyatech Maybe you're missing an 'end' statement in your podfile?

@AhrenFullStop
Copy link

Okay so I found the issue for me, so in my app initialization i used:

this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, ' ');

But the issue was actually a null string, meaning that the app was not successfully importing the variable "environment.ONESIGNAL_APP_ID".

I fixed that by simply hardcoding the App ID in the actual "OneSignalPush.m" file... It's not good practice but it stops the app from crashing.

@websystems-dev
Copy link

websystems-dev commented Nov 24, 2020

I fixed that by simply hardcoding the App ID in the actual "OneSignalPush.m" file... It's not good practice but it stops the app from crashing.

I'm stuck on this, can you show me where to hardcode it? @AhrenFullStop
I tried with line 95 in OneSignalPush.m - I deleted this line:
NSString* appIdStr = (appId ? [NSString stringWithUTF8String: appId] : nil);
and I inserted this:
NSSting* appIdStr = @"XXXXX-XXXXX-XXXX-XXXXX";
But it doesn't solve my problem.

Edit: I finally got it work, using version 2.10.1 of the plugin, which fixes the identifier bug and still works with non-wkwebview (removed in 2.10.2).

@nowjordanhappy
Copy link

pod 'OneSignal', '>= 2.11.2', '< 3.0'

Works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests