How to use Grocer feedback? - ruby-on-rails

I'm developing a ruby on rails app and I want to send push notifications to iOS devices. I'm using gorcer gem, and I'm also interested in having some feedback but I cannot make it work. I'm following the git tutorial (https://github.com/grocer/grocer#feedback).
feedback = Grocer.feedback(
certificate: "/path/to/cert.pem", # required
passphrase: "", # optional
gateway: "feedback.push.apple.com", # optional; See note below.
port: 2196, # optional
retries: 3 # optional
)
feedback.each do |attempt|
puts "Device #{attempt.device_token} failed at #{attempt.timestamp}"
end
And the console always return nil.
I tried to disable push notifications and to unistall the ios app to check if there are any feedback but I don't receive anything.
Does anyone know what is happening?
Thank you in advance.

I believe that your code is correct and the .each loop does run in your example (if there is at least 1 failed push notification returned from the feedback service).
I think there is a bug in Grocer that only allows iteration on the feedback service a single time, and then after that the feedback object is set to nil. See this bug: https://github.com/grocer/grocer/issues/80
I think this explains why the code would actually work, but then not return anything in the console.
As a side note, it seems that the best way to test the APNs feedback service is to register a valid device token through a production or ad-hoc app. Then delete the app from your device and send another push notification to that token. The feedback service seems to register that as a failed attempt immediately (and repeatably).

Related

Voip Push: Under what circumstances does didInvalidatePushTokenForType get called?

The documentation for didInvalidatePushTokenForType says its optional to implement and also says this
This method is invoked if a previously provided push token is no
longer valid for use. No action is necessary to request registration.
This feedback can be used to update an app's server to no longer send
push notifications of the specified type to this device.
Why on earth therefore would somebody not want to implement this? If the token is no longer valid then a server will never be able to send Voip pushes to that device again, so doesn't the app on the handset want to know as soon as possible if its invalided so it can send a new token to the server?
I've been trying to search for info and use of didInvalidatePushTokenForType() but it seems everybody just copy and pastes this method into their source code because everybody else has copy and pasted it. But nobody seems to ever do anything with it.
But seems to like it should be a vitally important method to make use of, so why does nobody apparently?
When would the token become invalid?
Thanks for the asking great question.
1) When would the token become invalid?
If we are update app from the App Store then APNS token doesn't change.
reinstalling the OS or Update OS or Reset iOS device then APNS token does change(Upgrade or downgrade OS).
Device token Invalidated or expired after 2 Years.
iOS9 and later device token changes if I reinstall an app.(As per my experience and Knowledge).
Download app from App Store then run your code using X-Code in this case device token will change.
2) Important of didInvalidatePushTokenForType() or Why? didInvalidatePushTokenForType() is optional
Let's clarify about didInvalidatePushTokenForType() method.
Once token got changed then called didInvalidatePushTokenForType() and didUpdatePushCredentials() method, So all code is placed in didUpdatePushCredentials() instead of didInvalidatePushTokenForType().
That's why Developer doesn't give important to didUpdatePushCredentials() method.
Find Reference from Here

Getting Invalid hex character error while sending Apple push notification via Mobile First Platform

I am trying to send Apple push notification via Mobile First Server. I did that setup three months back and things were working fine. I start facing problem 4-5 days back that states java.lang.RuntimeException: Invalid hex character: y
whenever I try to invoke push notification.
The server logs are as given below.
000004ed com.ibm.pushworks.server.notification.Mediator E FPWSE1081E: Failed sending notification. Please refer to the server log file for more details.
java.lang.RuntimeException: Invalid hex character: y
at com.notnoop.apns.internal.Utilities.charval(Utilities.java:132)
at com.notnoop.apns.internal.Utilities.decodeHex(Utilities.java:119)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:85)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
at com.ibm.pushworks.server.notification.apns.ApplicationConnection.sendNotification(ApplicationConnection.java:141)
at com.ibm.pushworks.server.notification.apns.APNSMediator.sendNotification(APNSMediator.java:106)
at com.ibm.pushworks.server.notification.Mediator$2.run(Mediator.java:89)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:483)
at java.util.concurrent.FutureTask.run(FutureTask.java:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:809)
Please suggest something to remove this error.
This issue can happen if the token you are using contains invalid hex characters.
Check whether you passing valid APNS token.
Use the following REST API :
http://www.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/apiref/r_restapi_push_device_registration_get.html
to check the APNS token for your subscription. If the APNS token is proper, verify if you can send a push notification using REST APIs.
We had the same problem with version 7.0. For some reason there was an invalid token in the PUSH_DEVICES table with the following string "32bytes"
We removed that register and the registers related in the PUSH_NOTIFICATIONS table and everything worked fine after that.

How do I use Parse.com's push notification feature for a change in PFObjects?

Can I use Parse.com’s push notification feature to send an array of PFObjects to the user when either a new one is added, or an existing one is deleted?? If so, how should I go about it? I’m writing an app for iOS. Any help would be much appreciated.
Edit:
After doing a bit of searching, I see I have to use the cloud code aftersave() method, and then send a push notification through JavaScript.
If anyone could provide examples of how to go about it, that would be great. In the meantime I'm going through the docs. Thanks again all.
The Parse Documentation really contains everything you need to get started. Writing the code that sends the actual notification is only a small part of the whole process that is required to send push notifications. Here are the steps required:
Create an SSL Certificate: create the cert via Apple Developer Center then export it with Keychain Application
Create Provisioning Profile: also done via Apple Dev Center.
Configure Parse App: Change Parse settings, then upload the cert you created in step 1.
Configure App in Xcode: Change app to use provisioning profile you created in step 2.
Add Code to Prompt user for Notifications: write the code in your app that asks a user if they want to receive Push notifications, then store their device ID in Parse Installation class.
Send the Notification: as mentioned earlier this is the easiest step of all. It can be done via the Parse Dashboard (Click on Push notifications when looking at the Data Browser), via the Parse API or via Cloud-code. I did it via Cloud-Code and it looks like this:
// Find the Installation (i.e. iOS Device) that belongs to my user*
var query = new Parse.Query(Parse.Installation);
query.equalTo('user', user);
Parse.Push.send({
where: query, // Set our Installation query
data: {
alert: "This is the notification message",
badge: "Increment"
}
}).then( function(){
console.log("Push notification successfully sent!");
});
*I added a field in my installation class that captures a user. That way I know which device belongs to which user and can send targeted Push Notifications.
Prepare for Release: When you release your app, you will need to do some additional configuration to get everything ready to release.
Again, I recommend the Parse Docs. They are comprehensive and very helpful. Let me know if you have any additional questions. Hope this helps!
** BTW: If you don't have any experience with cloud-code, then you can complete steps 1-5, then manually send the notifications via the Parse Dashboard.

Nothing happening when sending push notification with raix:push

I am trying to do a push notification from the browser console using raix (version 2.6.1).
I have tried pushing using the php script from this tutorial and it works with the certificate and key I have, but when I tried it with raix, nothing happen on the phone. I tried doing:
Push.send({from: "pushfrom", title:"hello", text:"world", token:{apn: "my_ios_device_token"}});
This is my config.push.json
{
"apn": {
"passphrase": "xxxxxxx",
"key": "aps_key.pem",
"cert": "aps_cer.pem"
},
"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
I have insecure package, but still, I tried adding the Push.allow and it didn't help.
How do I know whether the notification is actually being pushed to APNS or nothing is happening at all?
I'll try giving as close to an answer as possible:
Try using the $ meteor shell server console to send messages, server doesn't require allow/deny rules for sending (it's a client-side security)
Behind the scenes theres actually two collections:
Push.notifications - containing the pending notifications to send (these are queued)
Push.appCollection - This one keeps and maintain the tokens (eg. removes tokens if revoked by gcm/apn services)
So you can use the meteor shell to check if the client app registres a push token - if it does then you should be ready to send a message to it eg. directly via the meteor shell.
If you don't get tokens from the client in the Push.appCollection - then you have a config or certificate issue - that's the hard part of push notifications.
If you get tokens into the Push.appCollection then it's prop. something with the server setup. This could be certificates, I've added a guide on the raix:push repo for testing server certs. Also think in ports, you need to have some ports open for your server to communicate with the gcm/apn service. Also think in firewalls etc. depending on your/client setup and security level on the wifi etc.
Please help out improving documentation on the project - I built the thing and take alot for granted, so there might be a missing clue etc. the documentation.
You can also use the query: {} instead of sending to one specific token (while testing)
Latest version is at 2.6.6,
Push notifications is besides scrolling the smallest hardest feature to work with.
Kind regards Morten

Blackberry Push Notification-Push service sdk error

I install the blackberry sdk push server and i get app id and the port and i used the tutorial SamplePushEnabledApp i registred it with those data
Application ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPG Base URL** http://pushapi.eval.blackberry.com
Push Port: xxxxxxxx
For push initiator application i use the url https://XX.XX.XX.XX:8443/sample-push-initiator/ successfully create application using this, provide APPID, name and service level = Push-Essential. appID is same as provide by RIM.
I am trying to push msg from push menu item but it's give me error INVALID subscribers.
I had add subscribers name as APP_ID given by RIM, I had also tried device PIN No. as subscriber name but same error occurs.
plz help me to solve this issue.
Is there any solution for that?
There are three things required to sent a request from client side: APP id, push port and PPG base url
and three things required to send a response from server side :PPG base url, push username and push password
check whether you are using the exact credentials that are provided by Blackberry. If these dont match, it gives the above error
Though this may be very late to answer your problem/issue faced while implementing push service in BB device, But as, very recently I successfully able to implement this and I know how difficult to do this if you are not a BB app developer.
Hope you have gone through the below url for installing BB push service sdk on your PC.
http://developer.blackberry.com/bbos/java/documentation/push_service_sdk.html
http://developer.blackberry.com/bbos/java/documentation/developing_push_enabled_app.html
So for this if you are able to install the push service sdk(bpss-1.2.0.29.exe) you will be having one BPSS directory and under this the below thing will get created.
apache-tomcat-7.0.26
logs
pushsdk-high-level
pushsdk-low-level
Uninstall_BPSS
Push_Service_SDK_for_Java_InstallLog.log
Now I have used the pushsdk-low-level to push.
you can access this web app(push initiator cum content provider) by
https://localhost:8443/pushsdk-low-level
But before start pushing from this low-level push initiator you need to properly install the sample pushDemo app on your device.
NOTE: You can't test push service using the simulator.
Then you need to register with the Port(XXXXX), AppId(XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXX) and BPS server URL: http://cpXXXX.pushapi.eval.blackberry.com, Push Initiator Application URL: http://XX.XXXX.XXX.XX:8443/pushsdk-low-level, and use pubic(BIS) network selected.
Now let me tell you what this sample pushDemo does.
first it will try to use the Push initiator application URL to subcribe/store the BB device PIN to have the information about all PINs that have been register with your Push initiator(here our push-low-level app). But for testing this you can ignore by commenting the below code line in RegisterCommand.java class of the sample PushDemo app
ContentProviderProtocol.performCommand( ContentProviderProtocol.CMD_SUBSCRIBE, username, password, isEnterprise, tx );
Now run this modified app on you device and insert all data required for registration, you will be asked to input username/password, give anything. and register it should register successfully.
Once you have successfully registered your app on your BB device.
Now you should be able to push from your push-low-level web app to your pushDemo client app on your device. NOTE: the address that is been asked on push-low-level push page is nothing but the PIN of your device.
Ping me if you any other help on implementing this.

Resources