on 02-26-2015 4:52 PM
Hi all, thanks to Dan Van Leeuwen's excellent Introduction to Kapsel series I have been able to get push notification working with an Android device. I'm now trying to enable it on iOS. I have created the apns certificate and installed it on the push tab of the management cockpit for my app. .
I created an iOS version of the push demo app and deployed it to my iPhone (apparently the simulator does not support remote push notifications). When I run the app and tap on Register for Push I get the following error:
index.html
An error occurred in index.html (at line #1): SyntaxError: Unexpected identifier 'aps'. Expected ')' to end an argument list.
This seems to be coming from the onError function:
function onError(msg, url, line) {
var idx = url.lastIndexOf("/");
var file = "unknown";
if (idx > -1) {
file = url.substring(idx + 1);
}
alert("An error occurred in " + file + " (at line # " + line + "): " + msg);
return false; //suppressErrorAlert;
}
but I'm not sure what is causing it. Any help or resources you can point me to for getting it to work with iOS would be great.
Also, any tips on incorporating this functionality into the Fiori Client Kapsel app? I need to have that automatically register for push notifications (both iOS an Android).
Edit: Here is my registerForPush function code:
function registerForPush() {
var nTypes = sap.Push.notificationType.SOUNDS | sap.Push.notificationType.ALERT;
sap.Push.registerForNotificationTypes(nTypes, regSuccess, regFailure, processNotification,null); //GCM Sender ID, null for APNS
Second edit:
I'm also seeing this in the debug console of Xcode:
PushNotificationPlugin: Failed To Register For Remote Notifications With Error: Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x170668f80 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
I think this may due to a provisioning profile issue on my device and I am investigating that.
Thanks,
Dave
Message was edited by: Dave Fish
Hi, Dave. I got it working. Did you?
Are you using a server inside a corporate network? Maybe there's a port that need to be opened. See below:
Unable to use Apple Push Notification service (APNs) - Apple Support
Regards,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
No I didn't get it working. We did open the ports as mentioned in the article you linked to.
The APNS server was being reached but was returning an error that the server did not receive a JSON object.
If you could show me the message you were submitting to the SMP server to request the push notification that might help me identify what was wrong in my attempt.
Thanks,
Dave
Hey Dave, how have you been? Did you try asking Dan on his post http://scn.sap.com/docs/DOC-49529?
Regards,
Kevin
Hi Dave,
Sorry for resurrecting this old post, but we are basically stuck where you were a few months ago, and hoping you found a solution in the meantime to the APNS issue above.
The SMP log reads:
#WARN#APNSNotificationProcessor:extractPayload# Not a json object...#null#11798#null#3#null |
it connects successfully to the Apple sandbox servers:
getApnsService# APNS server address - gateway.sandbox.push.apple.com#null#11798#null#7#null |
getApnsService# APNS server port - 2195#null#11798#null#8#null |
getApnsService# APNS feedback address - feedback.sandbox.push.apple.com#null#11798#null#9#null |getApnsService# APNS feedback port - 2196#null#11798#null#10#null |
getApnsService# APNS feedback port - 2196#null#11798#null#10#null |
and then:
#ERROR# APNSNotificationStatusListener:connectionClosed##Connection closed: 8#null#11801#null#0#null |
Were you ever able to find a working JSON payload for Apple?
Android on the other hand is working fine with the below example payload:
{
"alert": "New Push notification",
"data": "Test message"
}
Thanks in advance for any help you or the other SCN members might be able to provide.
Max
Hi Max,
No I was never able to get this working and then I moved onto a different project so I haven't revisited it. I am taking the Developing Mobile Apps with SAP Hana Cloud Platform OpenSAP course and was planning to try and get this working with iOS this week. I'll let you know if I am able to get it working but I am disappointed that SAP has provided no working examples for this on iOS. Everything I've seen from SAP shows how to make it work with Android.
Dave
I turned on the debugging and tracing features for the server log and it is providing me with more information.
The request is definitely getting sent to the right APNS server (gateway.sandbox.push.apple.com).
The main issue I see in the log that could be causing the problem is that I'm getting the message Not a JSON object
I'm using the following in the payload section of the Advanced Rest Client:
{"alert":"New Vacation Approval Request", "data":"For (dfish) request (7)" }
I think Apple may require additional information in the JSON that is passed but if I use a JSON example from the Apple Developer Network site I get a 400 Bad Request error:
{
"aps" : {
"alert" : "You got your emails.",
"badge" : 9,
"sound" : "bingbong.aiff"
},
"acme1" : "bar",
"acme2" : 42
}
So I'm not sure what to do next. Does anyone have an example of JSON payload that works with APNS and SMP?
Thanks,
Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've made some progress but I still don't have push notification working for an iOS device yet. I resolved the error with the push notification plugin (mentioned above) by creating and installing a provisioning profile on my iPhone.
I also generated the necessary certificate on the Apple web site, exported it as .p12 certificate and imported it on the Push tab for the application in the management cockpit. When I send a push notification to the SMP server now I am getting back a 201 status, so that part is working fine.
But if I check the log file for the SMP server I see the following:
2015 02 28 12:16:52#0-700#WARN#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter##anonymous#http-bio-8080-exec-8####null#null#null#warn#Security#null#null#346b5a07-c3fe-448e-abdb-44a3ecb7ef02#null#1425176212144#null#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter#No CSI context found in the authentication session. Performing the role check using HttpRequest#null#727#null#1425151012141000#null |
2015 02 28 12:16:52#0-700#WARN#com.sap.mobile.platform.server.notifications.apns.handler.APNSNotificationProcessor##anonymous#push-async-3####null#null#null#warn#Push#null#null#8c41d808-c80b-44fd-98f3-3bd141e0af26#null#1425176212161#null#com.sap.mobile.platform.server.notifications.apns.handler.APNSNotificationProcessor:extractPayload# Not a json object...#null#728#Notification#1425151012161000#null |
2015 02 28 12:16:53#0-700#ERROR#com.sap.mobile.platform.server.notifications.apns.handler.APNSNotificationStatusListener##anonymous#Thread-279####null#null#null#error#Push#null#null#62b3abb2-833e-4d43-84e0-1ff605231bea#null#1425176213065#null#com.sap.mobile.platform.server.notifications.apns.handler.APNSNotificationStatusListener:connectionClosed#Connection closed: 8#null#730#null#1425151013065000#null |
Here is the URL that I am using to send the push notification:
http://10.0.1.124:8080/restnotification/application/com.mycompany.push
And here is the payload:
{"alert":"New Vacation Approval Request", "data":"For (i826565) request (7)" }
I'm not sure if the documentation is out of date but in one section it says the following:
---
Procedure
From the cockpit, select >Applications > Push
Under Apple, select APNS endpoint. "None" is the default endpoint value for all the applications.
Note
The default URL is for a production environment; for a development and testing environment, change the URL to gateway.sandbox.push.apple.com.
(DF: There is no place to set the URL to the gateway in the management cockpit)
Select Sandbox to configure APNS in a development and testing environment, or Production to configure APNS in a production environment.
Click Browse to navigate to the certificate file.
Select the file, and click Open.
Enter a valid password.
----.
So I don't know if the problem is that the request is attempting to go to the production APNS URL instead of the sandbox URL (I generated a sandbox certificate), or if the problem is caused by the server thinking that the payload is not a json object.
Thanks,
Dave
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.