Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: PushEvents


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jul 8, 2016 3:27 AM Last Post By: Steve Jordi
James Thornton

Posts: 1
Registered: 10/13/13
PushEvents  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 6, 2016 11:29 AM
I am trying to use the PushEvents via Kinvey Provider.
I have gone through all the tutorials and am able to register devices on both iOS and Android.
LoginUser - Working
Login - Working
RegisterDevice - Working

The events: DeviceTokenReceived,DeviceRegistered are received and the Tokens are in the Users list in Kinvey for both Android and iOS.

The problem is the PushReceived event is never getting fired when sending a push message from the Kinvey console. It shows that it was successful for 2 registered devices - one for ios, one for android.

There is never any indication of the Push message received on either device.

Any help would be appreciated
Steve Jordi

Posts: 111
Registered: 4/19/98
Re: PushEvents  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 8, 2016 3:27 AM   in response to: James Thornton in response to: James Thornton
Hi,
Not sure why you put that in the IDE forum, but anyway,
I was facing troubles too and not receiving anything from Kinvey when sending
a push notification.
It was to wrong parameters in the configuration on the server side.
I double checked the procedure to add an iOS certificate and to get the Android
keys. Did the procedure twice and then it started working.

Then on my project, I started to work only with iOS until it got right,
and then switched to Android.
The only problem I have with Android is that it seems to register the
device each time you deploy a new version, making Kinvey sending you
as many notifications as registrations.
If you debug/publish the Android app 32 times, you'll get 32 copies of
the notification. Not nice. iOS works fine.

Work with the KinveyProvider component:
For Android, make sure to type the project number (12 digits) in the
GCMAppID field not the project ID looking like "appname-1234"
You put that same number in Kinvey, this is the "Sender ID" field
in the Engagement > Push > Configuration > Android section.

Then in the KinveyProvider component set the Kinvey appkey field
to the "App ID" you get from the Kinvey dashboard (on top), as well
as the Master Secret (double click on it to make sure to select everything,
parts are hidden).

Then create a Kinvey user/password and set those values to the
KinveyProvider component.

On Kinvey, create an EdnPoint in the Business Logic section, name it
"myEndPoint" (or whatever) and add:
function onRequest(request, response, modules) {
var iOSAps = request.body.iosaps;
var push = modules.push;
var iOSExtras = request.body.iosextras;
var androidPayload = request.body.androidpayload;
var androidmessage = androidPayload.message;
var message = request.body.message;
push.broadcastPayload(iOSAps, iOSExtras, androidPayload);
response.complete( 200 );
}

Go back to the KinveyProvider component and set the
PushEndpoint field to "myEndPoint" (or whatever name you set)

Now on the PushEvents component, just set AutoActivate and
AutoRegisterDevice to TRUE

Attach the Provider to the KinveyProvider component and add
code for all OnEvents
Example for the OnPushReceived (in Delphi, not C++ but you get
the idea), it's just adding the received notification to a TMemo

Memo.Lines.Add('-- '+formatDateTime('dd-mm-yyyy hh:nn:ss', Now )+' --' ) ;
{$IF DEFINED(iOS)}
Memo.Lines.Add(AData.APS.Alert) ;
Memo.Lines.Add(AData.APS.Badge) ;
{$ENDIF}
{$IF DEFINED (ANDROID)}
If( AData.GCM.Title <> '') Then
Memo.Lines.Add('- '+AData.GCM.Title+' -') ;
Memo.Lines.Add(AData.GCM.Msg) ;
{$ENDIF}
Memo.Lines.Add('') ;

Hope this helps :-)

--
--
Steve JORDI - MSc in Geophysics/Volcanology
Geneva, Switzerland / Portland, OR, USA

On 2016-07-06 18:29:49 +0000, James Thornton said:

I am trying to use the PushEvents via Kinvey Provider.
I have gone through all the tutorials and am able to register devices
on both iOS and Android.
LoginUser - Working
Login - Working
RegisterDevice - Working

The events: DeviceTokenReceived,DeviceRegistered are received and the
Tokens are in the Users list in Kinvey for both Android and iOS.

The problem is the PushReceived event is never getting fired when
sending a push message from the Kinvey console. It shows that it was
successful for 2 registered devices - one for ios, one for android.

There is never any indication of the Push message received on either device.

Any help would be appreciated
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02