Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Support GCM for ios option #282

Closed
wants to merge 17 commits into from
Closed

Support GCM for ios option #282

wants to merge 17 commits into from

Conversation

jtbdevelopment
Copy link
Contributor

For issue #115, optionally receive notifications via GCM on ios by specifying senderID in ios options

@jtbdevelopment
Copy link
Contributor Author

i rebased up to latest master on your side and resolved conflicts

@macdonst
Copy link
Member

macdonst commented Nov 1, 2015

@jtbdevelopment this is awesome, I thank you for your contribution. I don't want you to think I'm ignoring it but I'll be on a business trip this week and may not be able to give it my full attention. I'll comment on it as soon as I can.

@jtbdevelopment
Copy link
Contributor Author

Sure, no worries.

On 11/1/2015 4:46 PM, Simon MacDonald wrote:

@jtbdevelopment https://github.com/jtbdevelopment this is awesome, I
thank you for your contribution. I don't want you to think I'm
ignoring it but I'll be on a business trip this week and may not be
able to give it my full attention. I'll comment on it as soon as I can.


Reply to this email directly or view it on GitHub
#282 (comment).

@pengyanb
Copy link

pengyanb commented Nov 5, 2015

@jtbdevelopment use GCM with iOS push plugin, I am getting a lot of dSYM warnings. Any ideas why?
screen shot 2015-11-05 at 13 23 57

Also, just a reminder, users need to set "Enable Bitcode" to No in the Xcode Project - Build Settings to prevent linker error.
screen shot 2015-11-05 at 13 26 00

Great job, thanks.

@jtbdevelopment
Copy link
Contributor Author

google/gcm#121

I suspect this is the issue.

On Wed, Nov 4, 2015 at 7:29 PM, pengyanb [email protected] wrote:

@jtbdevelopment https://github.com/jtbdevelopment use GCM with iOS push
plugin, I am getting a lot of dSYM warnings. Any ideas why?
[image: screen shot 2015-11-05 at 13 23 57]
https://cloud.githubusercontent.com/assets/6076799/10956436/926d5228-83c0-11e5-87bc-d13674cb1bc1.png

Also, just a reminder, users need to set "Enable Bitcode" to No in the
Xcode Project - Build Settings to prevent linker error.
[image: screen shot 2015-11-05 at 13 26 00]
https://cloud.githubusercontent.com/assets/6076799/10956473/ecf3a4ea-83c0-11e5-8e32-72d036c07272.png

Great job, thanks.


Reply to this email directly or view it on GitHub
#282 (comment)
.

@pengyanb
Copy link

pengyanb commented Nov 5, 2015

To suppress the warning messages: "now you can actually change the Debug Information Format in your Build Setting to DWARF rather than DWARF with dSYM. This would disable crashalytics etc for GCM but should remove the warnings. Next release should fix this completely."

@jtbdevelopment
Copy link
Contributor Author

I'm not entirely sure what your last reply is other than a quote from the
link? Is it a request or just a statement?

I think like bit code this is something that the project needs to set.
Given the large number of similar errors generated by other plugins I'm not
sure eliminating is feasible.
On Nov 5, 2015 2:52 PM, "pengyanb" [email protected] wrote:

To suppress the warning messages: "now you can actually change the Debug
Information Format in your Build Setting to DWARF rather than DWARF with
dSYM. This would disable crashalytics etc for GCM but should remove the
warnings. Next release should fix this completely."


Reply to this email directly or view it on GitHub
#282 (comment)
.

@pengyanb
Copy link

pengyanb commented Nov 6, 2015

@jtbdevelopment It is just a statement for how to suppress the warning messages at this stage.

@telemakhos
Copy link

@jtbdevelopment thanks for the awesome job. I might test this tomorrow... I'll ping you if I have any question.

@leonardobazico
Copy link
Contributor

@jtbdevelopment, thanks for the new feature.

How configure the cordova project to use GoogleService-Info.plist on xcode?

@jtbdevelopment
Copy link
Contributor Author

You don't. Just provide the senderid in plug-in init. The plist config is
more useful if you are using many services or pushing from client.
On Nov 12, 2015 2:00 PM, "Leonardo Bazico" [email protected] wrote:

@jtbdevelopment https://github.com/jtbdevelopment, thanks for the new
feature.

How configure the cordova project to use GoogleService-Info.plist on xcode?


Reply to this email directly or view it on GitHub
#282 (comment)
.

@leonardobazico
Copy link
Contributor

@jtbdevelopment, ok!

@leonardobazico
Copy link
Contributor

Anyone knows why GCM don't sent to APNS?
The status in GCM console is accepted, but my iOS device don't received the notification.

@pengyanb
Copy link

@leonardobazico If you are using the "Development Certificate" for APNS, remember to set the "gcmSandbox" to true for ios when you calling the push.init.

PushNotification.init(
    {
        "android":{"senderID":GCM_SENDER_ID},
        "ios":{"alert":"true", "badge":"true", "sound":"true", "senderID":GCM_SENDER_ID, "gcmSandbox":"true"}, 
        "windows":{} 
    }
);

@zalatnaicsongor
Copy link

Works great (notifications are handled well), the only issue that came up is that if https://github.com/EddyVerbruggen/cordova-plugin-googleplus is added to the project, then the build breaks at the linking stage because of duplicate symbols.
The only way to fix this linker error is to delete the duplicated .a files from the project.

@leonardobazico
Copy link
Contributor

@pengyanb I setted gcmSandbox to true.

@pengyanb
Copy link

@leonardobazico Does it work if you send a push notification via APNS directly with the certificate you have? I remember I was having the same problem. For my case, I tested it with a java program (https://code.google.com/p/javapns/) to push notifications via APNS and it works. The issue is just that I didn't set the gcmSandbox parameter and GCM forwarded notifications to Apple Production Server.

@leonardobazico
Copy link
Contributor

@pengyanb I tested with APN Tester (https://itunes.apple.com/br/app/apn-tester-free/id626590577?mt=12) from Mac App Store. This works great.

What is the status of your messages in GCM console?

@telemakhos
Copy link

@macdonst This looks ready to rock... Are you going to merge it anytime soon?

@AdriVanHoudt
Copy link
Contributor

@macdonst any progress on this. It would be very cool to just use gcm for both

@jacksongross
Copy link

+1 a merge with this would be great!

Resolved conflict with phonegap/phonegap-plugin-push
@jtbdevelopment
Copy link
Contributor Author

merged to latest base with updates pull request from @leonardobazico

@macdonst
Copy link
Member

macdonst commented Dec 1, 2015

@jtbdevelopment I like the functionality but I have a few questions:

  1. Did you consider figuring out whether or not the app was running in the sandbox by using TCMobileProvision? That way we could eliminate the gcmSandbox option in options.ios.
  2. Is there some way we can include the Google/CloudMessaging code without needing to add it to the plugin? Perhaps there is a way we can include it via the <framework/> tag or via CocoaPods?

@fredgalvao
Copy link
Collaborator

@macdonst I saw talk about making <framework> on cordova work with cocoapods or external third party libraries as dependencies in the mailing list recently, but I'm almost sure it's not yet available.

Actually, I found the cordova-discuss topic on this, and it indeed seems to be in the design phase still. Might be worth to poke the mailing list on this?

@macdonst
Copy link
Member

macdonst commented Dec 1, 2015

@fredgalvao yup, Shaz and Holly are working on making all core plugins available as CocoaPods, including this one. I will chime in there as well. Might just merge this and move to CocoaPods once available.

@jtbdevelopment
Copy link
Contributor Author

I toyed with idea of trying to turn a simple cocoapod project into a
framework myself (not sure if it's possible but thought about it) but felt
this way was more verifiable to anyone with security concerns. If I built
a framework project someone would have to track that down and verify it
contained non modified Google code.

This way someone with concerns can easily compare their own sample gcm
xcode project with provided files.
On Dec 1, 2015 3:23 PM, "Simon MacDonald" [email protected] wrote:

@fredgalvao https://github.com/fredgalvao yup, Shaz and Holly are
working on making all core plugins available as CocoaPods, including this
one. I will chime in there as well. Might just merge this and move to
CocoaPods once available.


Reply to this email directly or view it on GitHub
#282 (comment)
.

@gamaralf
Copy link

gamaralf commented Dec 3, 2015

+1 please merge

@jtbdevelopment
Copy link
Contributor Author

This has been resynced with latest master and docs revamped to latest format. Regarding TCMobileProvision it looks interesting, but I don't currently have time to play with it.

@macdonst macdonst added this to the Release 1.5.0 milestone Dec 8, 2015
@@ -122,6 +161,27 @@ - (void)init:(CDVInvokedUrlCommand*)command;
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif

// GCM options
[self setGcmSenderId: [NSString stringWithString: [iosOptions objectForKey:@"senderID"]]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtbdevelopment this will cause:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'

if the options.ios object doesn't have a senderID object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bah bad checkin - corrected. At one point I forgot to make the string
defined as strong and was getting corrupted sometimes as you'd expect if
you fail to keep the reference - tried that before I realized real issue
and forgot to undo it. Did a couple of quick checks with latest build to
make sure it doesnt explode anymore

On Mon, Dec 7, 2015 at 8:06 PM, Simon MacDonald [email protected]
wrote:

In src/ios/PushPlugin.m
#282 (comment)
:

@@ -122,6 +161,27 @@ - (void)init:(CDVInvokedUrlCommand*)command;
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif

  • // GCM options
  • [self setGcmSenderId: [NSString stringWithString: [iosOptions objectForKey:@"senderID"]]];

@jtbdevelopment https://github.com/jtbdevelopment this will cause:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'

if the options.ios object doesn't have a senderID object.


Reply to this email directly or view it on GitHub
https://github.com/phonegap/phonegap-plugin-push/pull/282/files#r46902846
.

@macdonst
Copy link
Member

macdonst commented Dec 8, 2015

@jtbdevelopment running into an issue where I can successfully register with GCM. Same as described in #115

@macdonst
Copy link
Member

macdonst commented Dec 8, 2015

Merged into 1.5.x branch.

@telemakhos
Copy link

👏👏👏

@macdonst
Copy link
Member

I'm closing this PR as it has been merged into v1.5.x and will become part of master soon.

@chetstriker
Copy link

Any chance of a 1.5.x build without gradle? I'm using XDK which doesn't support gradle and only can use version 1.4.5. This works for android devices but doesn't seem to work for iOS as i understand it.

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.