iOS Push Notification returning the number 94 - ruby-on-rails

I'm integrating push notification for iOS using the gem houston on Ruby on Rails as the web service but whenever I try to send a push notification, it only returns the number "94". Tested it a few hours ago, it returned the number "83" instead. What do you think is causing this and what does those numbers mean?
Code:
token = params[:user]["device_token"]
certificate = File.read("../flux-ws/public/certificates/#{PEM_FILE}")
passphrase = ""
connection = Houston::Connection.new(GATEWAY_URI, certificate, passphrase)
connection.open
notification = Houston::Notification.new(device: token)
notification.alert = {
:body => "HELLO WORLD"
}
notification.badge = 57
pushed_data = connection.write(notification.message)
connection.close
Return value:
{"pushed_data":94,"status":200}

Nevermind, guys. I solved it. The bundle id on the pem file didn't match with the bundle id on my project. That was what caused it and after I matched both, it delivered the push notification successfully.

Related

BadDeviceToken when trying to send the notification (APN) with apnotic gem Rails

I am trying to fire a notification using gem 'apnotic'.
connection = Apnotic::Connection.development(cert_path: "#{Rails.root}/lib/mondofiPush.pem", cert_pass: "")
token = "5e67102820556ee177ffbe0a64ee3a391b89ac61ff2602c97587e838ef93cca"
notification = Apnotic::Notification.new(token)
notification.alert = "Notification from Apnotic!"
response = connection.push(notification)
But in response I get:
{"reason"=>"BadDeviceToken"} we checked that token if fine.
Can anybody please guide me to solve this?

Rpush notification fails to deliver

I am new to Rails. I am trying to send push notification using rpush gem.
I am following these steps:
n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("android_app")
n.registration_ids = ["#{d.device_token}"]
n.data = { title: "#{self.title}"}
n.save!
The notification gets saved but is not getting delivered, and I get the following error description:
"Unable to deliver notification 10, received error (Failed to deliver to all recipients. Errors: NotRegistered.)"
Not able to understand the issue here. Please help me.
Thanks!
When you find above mentioned message in your log, means, as said #abielita and rpush wiki documentation, the identification_id GCM is using to send notification, is no more valid.
Device with (d.device_token) as registration token, is no more registered on GCM (Firebase) Service.
This message come for a specified reason: adapt your code to this condition.
Maybe is better destroy your "d" record !?
Becomes helpful Rpush.reflect in config/initializers/rpush.rb
Uncomment event notification on.gcm_invalid_registration_id and add your code inside block
e.g.
on.gcm_invalid_registration_id do |app, error, registration_id|
Device.where(registration_id: registration_id).take.destroy
end
and encloses your sending notification code inside a conditional check
unless(d.nil?)
n = Rpush::Gcm::Notification.new
n.app = Rpush::Gcm::App.find_by_name("android_app")
n.registration_ids = ["#{d.device_token}"]
n.data = { title: "#{self.title}"}
n.save!
end
I hope it help

How to configure Push Notification in Mobile App Buider?

I'm using a Mobile App Builder to make some prototype. One of them I need to send push notification. So, I created a App with App Builder and configure a push settings using Push Notification Services (App GUID and App Route).
After that, I was defined settings a Apple Certificate to send push (https://new-console.ng.bluemix.net/docs/services/mobilepush/t_push_provider_ios.html)
So, when I try to send push notification using Push Notification Services (Bluemix) I receive a msg:
1 - Internal server error. No devices found.
When I see a log in XCode I Found:
registerDeviceToken:completionHandler:]_block_invoke_2 in IMFPushClient.m:116 :: Response of device registration - Response is: httpStatus: 201
responseHeaders: {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Thu, 12 May 2016 18:21:22 GMT";
Location = "https://enviarpush.mybluemix.net:443/imfpush/v1/apps/428e6b13-2cc7-4f99-8d7e-9741d6742709/devices/AFAF9994-535D-4F6C-9789-317E680833A8";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "OK OK";
"X-Global-Transaction-ID" = 2301423703;
"X-Powered-By" = "Servlet/3.0";
}
responseJson: {
createdMode = API;
createdTime = "2016-05-12T18:21:22Z";
deviceId = "AFAF9994-535D-4F6C-9789-317E680833A8";
href = "https://enviarpush.mybluemix.net:443/imfpush/v1/apps/428e6b13-2cc7-4f99-8d7e-9741d6742709/devices/AFAF9994-535D-4F6C-9789-317E680833A8";
lastUpdatedTime = "2016-05-12T18:21:22Z";
platform = A;
token = 7574a3f1d14a7a01f8d43663cef686b3cb66a634b71ed20608a739c4f55356db;
userId = "";
}
Response text: {"createdTime":"2016-05-12T18:21:22Z","lastUpdatedTime":"2016-05-12T18:21:22Z","createdMode":"API","deviceId":"AFAF9994-535D-4F6C-9789-317E680833A8","userId":"","token":"7574a3f1d14a7a01f8d43663cef686b3cb66a634b71ed20608a739c4f55356db","platform":"A","href":"https://enviarpush.mybluemix.net:443/imfpush/v1/apps/428e6b13-2cc7-4f99-8d7e-9741d6742709/devices/AFAF9994-535D-4F6C-9789-317E680833A8"}
This infos confirm that my device was register, I'm right?
Thanks
Moving forward we will be integrating the device registration, for the period we are experimental we will be creating a number of blog posts that explain some of the key integration you will need to do manually in code. This will include how we recommend integrating with a bluemix backend.
You have to register a device to the IBM Push Notifications Service in order for it to successfully receive push notifications. I would suggest looking at the following documentation:
Enabling iOS applications to receive push notifications
There is also a sample available that demonstrates these capabilities:
HelloPush

rpush notification, saves notification but not sending. Ionic receive message Notification received

Are there any documentations regarding the data field of the Push Notification message i mean n.data { }. what does it mean?
I seem to be having the same issue as well
This is my code
n = Rpush::Apns::Notification.new
n.app = Rpush::Apns::App.find_by_name("Loanstreet Partners")
n.device_token = #user_auth_token.device_token # 64-character hex string
n.alert = "New Case Submission: " + la.case_code
n.data = { foo: :bar }
n.badge = 1
n.save!
Rpush.push
Rpush.apns_feedback
In my rpush_notifications table, i see the notification created but in my rpush_feedback it is empty. not sure why it doesn't get sent. Anyone has a clue?
I don't get any error or anything as well. So I'm sort of confused.
I do however get a Notification received from Ionic log but i dont see any notification.

houston apn push doesn't do anything (no errors)

I'm trying to use Houston to send a push notification. I recreated the provisioning profile, can upload a device token successfully, but when I push using apn the console shows no readout. Is there a way to log what APN is doing? (Submitted a github issue; posting here hoping someone's ran into this.
Running this code returns nothing. I've tried removing spaces & <> from the device token too, same result.
Using rspec 3.1.0
Using simplecov-html 0.8.0
require 'houston'
# Environment variables are automatically read, or can be overridden by any specified options. You can also
# conveniently use `Houston::Client.development` or `Houston::Client.production`.
APN = Houston::Client.production #tried development, same result
APN.certificate = File.read("/Users/quantum/Documents/cliqupprodcerts.pem")
# An example of the token sent back when a device registers for notifications
token = "tokentoken"
# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app
notification = Houston::Notification.new(device: token)
notification.alert = "Hello, World!"
# Notifications can also change the badge count, have a custom sound, have a category identifier, indicate available Newsstand content, or pass along arbitrary data.
notification.badge = 57
notification.sound = "sosumi.aiff"
notification.category = "INVITE_CATEGORY"
notification.content_available = true
notification.custom_data = {foo: "bar"}
# And... sent! That's all it takes.
v = APN.push(notification)
puts v
~
EDIT: I had tried production before, production & development don't work. puts notification.errors after sendings shows nothing.
First you should check whether you have had a develop profile that has a permission to push remote notification.
Then if your device is iOS 8.0 or later ,"Please use registerForRemoteNotifications and registerUserNotificationSettings: instead");
The last, you can do follow the steps of "houston"

Resources