Skip to content

Fix for iOS 8 & previous in Xcode 6 & previous#317

Closed
sclement41 wants to merge 3 commits intophonegap-build:masterfrom
sclement41:master
Closed

Fix for iOS 8 & previous in Xcode 6 & previous#317
sclement41 wants to merge 3 commits intophonegap-build:masterfrom
sclement41:master

Conversation

@sclement41
Copy link
Copy Markdown

This fixes the issue of the registration not working in plugin version 2.3.1 for iOS 7 & previous. The fix checks the SDK version at compile time, and then uses the appropriate methods at runtime.

@hirbod
Copy link
Copy Markdown

hirbod commented Sep 21, 2014

Thanks for your Pull Request, seems like to be what I was looking for since the plugin does not work anymore on iOS 7 (with Xcode 5)

Your PR still does not work on XCode 5, returns some compiling errors (9)

Could you provide a way for compiling also in XCode 5 ?

bildschirmfoto 2014-09-21 um 16 16 34

@hirbod
Copy link
Copy Markdown

hirbod commented Sep 21, 2014

#249

This PR works perfectly for me (at least on iOS 7, XCode 5.1.1)

@sclement41
Copy link
Copy Markdown
Author

I added conditional compile guards around the use of UserNotificationTypes, that fixes the compilation issue.

@pkayfire
Copy link
Copy Markdown

@sclement41, thanks for this fix!

@sharat
Copy link
Copy Markdown

sharat commented Sep 22, 2014

Notification is not working with 2.3.1. When we rolled it back to 2.1.1 it's working.

@RobinHerzog
Copy link
Copy Markdown

Works perfect ! iOS 7 & 8 on Xcode 6, cordova edge

@hirbod
Copy link
Copy Markdown

hirbod commented Sep 22, 2014

@sclement41 thanks for upgrading. Works perfectly on iOS 7.1.2 and XCode 5.1.1
It's incredible that the plugin mantainer just updated PushPlugin to 2.3.1 without notifying anybody and breaking XCode 5 and iOS 7 compatibility. I was wondering for hours why the callback did not get called. Thanks, you really saved my day!

@scotthooker
Copy link
Copy Markdown

Let's not be too harsh on the maintainer without automated test scripts its hard to test for everything!

@hirbod
Copy link
Copy Markdown

hirbod commented Sep 22, 2014

Of course you're right and it's open source. I have much respect for that. I guess I'm just a little bit angry of myself. The problem was that everything worked fine 2 weeks ago, then I started a new project and just downloaded everything with Cordova CLI and I was trying 10 hours to debug my JS-Code and could not figure out what happened ( till I used to visit this Github page... should have done this before :( )

@ghost
Copy link
Copy Markdown

ghost commented Sep 22, 2014

Will it merged to phonegap build?

@burin
Copy link
Copy Markdown

burin commented Sep 22, 2014

I've made a test scenario matrix to wrap my head around the before and after of this patch. Hopefully this helps everyone else too. Please let me know if my assumptions are wrong:


Before:


        |    ios 7   |     ios8
----------------------------------
xcode 5 |     √      |  "ios7 mode"
----------------------------------
xcode 6 |     √      |       X 
----------------------------------


This patch:

        |    ios 7   |     ios8
----------------------------------
xcode 5 |     √      |       √ 
----------------------------------
xcode 6 |     √      |       √ 
----------------------------------

@sharat
Copy link
Copy Markdown

sharat commented Sep 22, 2014

We use Adobe's build and reverted to 2.1.1. Looks like this has to be merged and pushed.

@ghost
Copy link
Copy Markdown

ghost commented Sep 25, 2014

This has fixed push notifications for us on ios7 and ios8, thank you very much for this patch. :)

@sbryfcz
Copy link
Copy Markdown

sbryfcz commented Sep 26, 2014

Thanks for this patch. Saved me huge headaches.

@jrstanley
Copy link
Copy Markdown

I notice that badge counts aren't updated when the app is closed, although can't be entirely sure whether or not this is entirely related to this patch. It's possible other issues could be at play. Could anyone confirm this works for them?

@tianissimo
Copy link
Copy Markdown

@jrstanley I have this problem too. But for me, the badge doesn't display at all.

@wildabeast
Copy link
Copy Markdown
Member

A version 2.4.0 of this plugin has been added to Phonegap Build, which includes this patch. Please test and get back, and I will merge it into the mainline. @oscarabilleira

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

@wildabeast where can we grab version 2.4.0?

@wildabeast
Copy link
Copy Markdown
Member

@hirbod on Phonegap Build it can be found here: https://build.phonegap.com/plugins/1199. I haven't merged and tagged it yet because I was hoping for some help with testing (I can't currently do it). But you can find the merged dev branch here: https://github.com/phonegap-build/PushPlugin/tree/sclement41-master.

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

@wildabeast
Thank you very much. I installed it with

cordova plugin add https://github.com/phonegap-build/PushPlugin#sclement41-master

@bau720123
Copy link
Copy Markdown

hi everybofy
2.4.0 solved the problem
https://build.phonegap.com/plugins/1199
thanks @wildabeast

@sharat
Copy link
Copy Markdown

sharat commented Oct 4, 2014

@bau720123 Did it solve badge count issue?

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

@sharat
No...

@tianissimo
Copy link
Copy Markdown

Try this #332
It works for me on IOS < 8 & Xcode 6.

@bau720123
Copy link
Copy Markdown

hi @sharat and @hirbod
I am using PGB 3.63 (build.phonegap.com)
if you mean...

step 1
send a message to apns (I am using PHP incuding the "badge" attribute)

step 2
receive a message by step 1 from your javascript and got a exactly "badge" number

yesI did it

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

I receive the badge attr in the app, but when my app is closed the badge counter does not change.
Phonegab 3.5.0 and plugin version 2.4.0 on iOS7 (compiled with Xcode 5)

Messages working fine...

@bau720123
Copy link
Copy Markdown

hi @hirbod
could I ask why you know the "badge counter" does not change after app close
if alert the "event.badge" once again ?

I am using PGB 3.63 and plugin 2.40 on iOS 8.02

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

@bau720123 Before I used 2.1.1. When I send a push message trough my server I received a message and the badge counter on my app changed. (while app was closed) Now I do receive the message but the badge counter does not change either get set to anything..

@sharat
Copy link
Copy Markdown

sharat commented Oct 4, 2014

@hirbod Let me try that. Thank you.

@bau720123
Copy link
Copy Markdown

hi @hirbod
I tried once again

step 1,send a message from php

step 2,receive a message (app not open yet before),the desktop's "badge number" will show
-click the upper status bar (the push message),it will trigger the javascript "badge" behavior,back to the desktop,the "badge number" will Disappear
-click the app icon directly,it will not trigger the the javascript "badge" behavior (right behavior),but the desktop's "badge number" will Disappear too

PS
I tried many times,when I in step 1,I change the "badge number" to several number,all correctly done
could you more Clear to point out your operating procedures

PS2
sleep for now

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 4, 2014

Are you on iOS8 ? Cause as I told you before, I'm on iOS7 and this could be the problem. If my app is closed, the springboard badge counter will not be set. If the app is open and I call manually

              pushNotification.setApplicationIconBadgeNumber(this.successHandler, this.errorHandler, 2);

it works. But actually, this call should work inside of my onNotificationAPN function (as it did on PushPlugin Version 2.1.1) I'm not the only person with this problem as you can read in the beginning. This PR fixes the main issue with registering and calling the callbacks but also broke the badge counter - at least for me on iOS 7.1.2

@bau720123
Copy link
Copy Markdown

hi @hirbod
yes I am in iOS8.02 that I told you before too XD
ok...understand what you mean...maybe was a bug in iOS7
let me wait for @wildabeast reply

@khawkins
Copy link
Copy Markdown

khawkins commented Oct 5, 2014

It's worth noting that the #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 approach only ensures the proper functionality for the platform that built the plugin. It's a preprocessor definition, which is only going to apply at compile time.

So, for instance, if you build the plugin with Xcode 5 / iOS 7, your app is not going to work for iOS 8 devices. Conversely, if you build with iOS 8, the compiled app is not going to work on < iOS 8 devices. You need a runtime check.

You can take a look at the way we did it with respondsToSelector: and NSInvocation here. I was going to submit a PR, but it seems like this area is in quite a bit of flux already.

@sreejith-m-sreedharan
Copy link
Copy Markdown

We are facing the same issue in devices with < iOS 8 , we got the push messages but the badge number did not update. in iOS 8 , it is working fine. Version 2.1.1 was working fine with devices having iOS version < 8. I had issues with 2.3.1. I think you should refer to the version 2.1.1 code to see what have been changed to break the code.

@wildabeast
Copy link
Copy Markdown
Member

This has been merged.

@wildabeast wildabeast closed this Oct 6, 2014
@sharat
Copy link
Copy Markdown

sharat commented Oct 6, 2014

@wildabeast does this fix the badge count issue?

@wildabeast
Copy link
Copy Markdown
Member

@sharat no. This is a pull request, and I have merged the code contained in it. The badge count issue is separate and should be discussed in another thread such as #348. I myself cannot currently apply time to looking at a fix for this, but can merge fixes and deploy to PGB if there is a consensus on a tested fix.

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 7, 2014

@wildabeast seems like your the only hope right now as nobody seems to have any idea with this bug. and did someone verify @khawkins statement? cause this plugin seem to work on iOS 7 and iOS 8 (with broken badge counter on iOS 7). I will try @khawkins fork later and will report

@khawkins
Copy link
Copy Markdown

khawkins commented Oct 7, 2014

@hirbod I'd be interested to hear how it goes. I unfortunately also do not have time to rationalize our changes back into the main repo here at the moment. I've heard from folks on our side that our repo seems to work, but I don't know how exhaustively they've tested it.

@hirbod
Copy link
Copy Markdown

hirbod commented Oct 7, 2014

Hello everybody, hi @khawkins,

just installed @khawkins fork (after removing the PushPlugin)

cordova plugin rm com.phonegap.plugins.PushPlugin
cordova plugin add https://github.com/forcedotcom/PushPlugin#unstable

Open Xcode, Open Plugins, Mark all Files with .m / .mm (not .h) and then, on the right side, toggle "Target Membership" active (this will prevent the Cordova 3.5.0 bug "CDVPlugin not found")

So.... Big thanks. It just works! Bade counter works fine and I do receive push notifications. There is just one thing that seems to be different: the object.

Before I could access the message with "event.alert".. Now it is a bit different.
event.payload.aps.alert - so the object seemed to be modified. But thats fine for me.

iOS 7.1.2, Xcode 5.1.1

Now it's up to you guys. Try to compile with iOS 8 on Xcode 6. When it work, we should remove @sclement41 PR and Push @khawkins repo to the official build!

Thank you very much @khawkins

@carlosbalda
Copy link
Copy Markdown

Does this version solve the problem with the asidentifier manager that the 2.3.1 version has?.... Apple is rejecting my app due to that

@JavierMartinz
Copy link
Copy Markdown

Does anybody could test @khawkins's fork? https://github.com/forcedotcom/PushPlugin#unstable

I added it and register sucessfuly, but the device (iOS 8) is not receiving any push.

@hirbod
Copy link
Copy Markdown

hirbod commented Nov 16, 2014

It works. The object in JavaScript is just different. You need to access it trough event.aps.payload.message etc. Just try to put event in console.log()

@JavierMartinz
Copy link
Copy Markdown

I am using the ngCordova's $cordovaPush wrapper (http://ngcordova.com/docs/#Push) with the code:

    // push received!!
  $scope.$on('pushNotificationReceived', function(event, notification) {
    console.log('Push received!');
    console.log(event, notification);
  });

but the block is never being executed

@ipalaus
Copy link
Copy Markdown

ipalaus commented Nov 16, 2014

Same here @JavierMartinz, I've been trying to make it work with that simple snippet on iOS8+ and no luck yet.

@JavierMartinz
Copy link
Copy Markdown

I just tested it without ngCordova's wrapper and it is also not working. Did you test it with iOS 8.1 @hirbod ?

@hirbod
Copy link
Copy Markdown

hirbod commented Nov 18, 2014

HI @JavierMartinz ,

works perfectly on iOS 8.1 with iPhone 6+ (real device)

@JavierMartinz
Copy link
Copy Markdown

I was using production certificates instead of development ones, my fail 👎

@hirbod
Copy link
Copy Markdown

hirbod commented Nov 18, 2014

Fine, I'm lucky you found the problem :) 👍

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

Successfully merging this pull request may close these issues.