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

iOS 13 Device token key is broken #13

Open
RamyaAshika opened this issue Mar 9, 2020 · 2 comments
Open

iOS 13 Device token key is broken #13

RamyaAshika opened this issue Mar 9, 2020 · 2 comments

Comments

@RamyaAshika
Copy link

Hi,

As per the apple updates, iOS device token key is generating {length = 32, bytes = 789dc438 6d688f2c ... f6b37ddb 8a504523 }" instead of <789dc438 6d688f2c e2dd66d8 0d335454 5ce29f0f ed71234a f6b37ddb 8a504523>"

For reference, please go through this link.
https://fluffy.es/4-ios13-breaking-changes/#push

So, what is the fix for this, I'm using cordova push notification plugin only and I'm facing this problem.Any updates?

@codebycharles
Copy link

Hi,

As per the apple updates, iOS device token key is generating {length = 32, bytes = 789dc438 6d688f2c ... f6b37ddb 8a504523 }" instead of <789dc438 6d688f2c e2dd66d8 0d335454 5ce29f0f ed71234a f6b37ddb 8a504523>"

For reference, please go through this link.
https://fluffy.es/4-ios13-breaking-changes/#push

So, what is the fix for this, I'm using cordova push notification plugin only and I'm facing this problem.Any updates?

I've submitted a pull request to fix this issue, you can have a look.

@DevelupDB
Copy link

Hi, sorry for my English, I have the same problem and i could fix it.

The truth is, the easiest thing for some is to change the plugin since it is outdated and is not fully compatible with ios 13.

But if you want to continue using this plugin you must edit the PushPlugin.m file in the folder of plugin, more precisely the code of line 291, I leave the example in case someone needs it, I have already tried it and it has worked for me.

Code of Plugin:

  NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""]
                      stringByReplacingOccurrencesOfString:@">" withString:@""]
                     stringByReplacingOccurrencesOfString: @" " withString: @""];

Remplace with this code:

const unsigned *tokenBytes = [deviceToken bytes];

NSString *token = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
                            ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
                            ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
                            ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];

To update the plugin code on the platform, you need to remove the platform and re-add it

cordova platform rm ios
cordova platform add ios

Regards

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

No branches or pull requests

3 participants