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

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"

Related

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

FCM Cannot recieve notification when app in background react native ios when custom data sent

i have succesfully integrating react-native-fcm and
i am getting notification when i am sending from firebase console (in foreground,background,and killed state of app)
but when i am sending it from our server with custom data i cannot recieved when app is in (killed,background) state
i have also tried content-availble:true in data object
below is the notification data which i am sending
{
aps = {
"content-available" = 1;
};
body = "Get a free T-Shirt #WROGN on every purchase via Shopholix. T&C apply.";
"gcm.message_id" = "0:1475746605785619%9a4a567a9a4a567a";
"gcm.notification.data" = "{\"image\":\"http:\\/\\/res.cloudinary.com\\/saurabh\\/image\\/upload\\/v1469791885\\/media\\/yljgxgmfg1qbulxzwakm.png\",\"user_type\":\"all\",\"screen\":\"store\",\"id\":\"56d7e33ce69f7c8f06550002\",\"title\":\"Shopholix\",\"message\":\"Get a free T-Shirt #WROGN on every purchase via Shopholix. T&C apply.\",\"body\":\"Get a free T-Shirt #WROGN on every purchase via Shopholix. T&C apply.\"}";
"gcm.notification.priority" = high;
id = 56d7e33ce69f7c8f06550002;
image = "http://res.cloudinary.com/saurabh/image/upload/v1469791885/media/yljgxgmfg1qbulxzwakm.png";
message = "Get a free T-Shirt #WROGN on every purchase via Shopholix. T&C apply.";
screen = store;
title = Shopholix;
"user_type" = all;
}
Any help would be appreciated
Thanks,
Your content_available is set to 1. I'm pretty sure when using FCM, you should use true or false. Correct me if I'm reading your payload structure in a wrong way, but are you specifying the content_available separate from the GCM payload?
Also, the priority parameter should be outside the notification payload parameter.
See here for more details.
Were you able to resolve your issue?
Looking at the JSON, if it is exactly how you're sending it, then it is not well formed. All of the keys need to be strings surrounded by quotes. And each key-value pair needs to be comma-separated, not semi-colon.

push notification doesn't work in grocer

I am going to send a notification to ios devices by rails backend.
I have added grocer gem to Gemfile and then installed it in the project.
gem 'grocer'
I planed to send a notification in background mode. So I created resque job and added the grocer logic in app/jobs/notificationsender.rb like this.
def self.perform(language)
#lang = language
# Thread.new do
while true
begin
pusher = Grocer.pusher(certificate: "#{Rails.root}/lib/notification/cer.pem", # required
passphrase: "llvc", # optional
gateway: "gateway.sandbox.push.apple.com", # optional
port: 2195, #optional
retries: 3)
feedback = Grocer.feedback( certificate: "#{Rails.root}/lib/notification/cer.pem", # required
passphrase: "llvc",
gateway: "feedback.sandbox.push.apple.com",
port: 2196,
retries: 3)
note = Grocer::Notification.new(
device_token: device_token,
alert: message,
sound: 'default',
badge: 0,
expiry: Time.now + 60*60,
content_available: true,
custom: {
"linkname": linkname,
"linkurl": linkurl
}
)
feedback.each do |attempt|
puts "Device #{attempt.device_token} failed at #{attempt.timestamp}"
end
pusher.push(note)
rescue Exception => e
puts e.class
puts e
end
sleep(5)
end #while
end
I got a device token from iphone and sent it to backend.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
_deviceToken = deviceToken;
// Store the deviceToken in the current installation and save it to Parse.
if (currentInstallation == nil) {
currentInstallation = [[BSGInstallation alloc] init];
}
currentInstallation.delegate = self;
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
I downloaded an apple pushnotification development certificate and generated p12 from it and then created cer.pem file from command line.
I signed the ios project with app development cer for debug and distribution for release and assigned development provisioning. Of course I added device identifier to the provisioning correctly.
After building ios, backend, resque job I got a notification after every 5 seconds in iPhone. I installed the app on iPad. but the notification doesn't get on the iPad. Of course the id of iphone and ipad were correctly registered. And I confirmed the device token of iphone and ipad was passed on the Grocer::notification.new()
but the notification doesn't work in iPad. So I reset the server and reinstalled on each devices. At first I tested for iPad. the result was the same. And then I move onto iPhone. the system also didn't work in the iphone. Before it worked. It was very strange.
So I want to know the followings.
1) the reason why the notification is received by iphone or ipad. I want to know the as many branches as possible so that i can detect the reason quickly by following the steps.
2) Can I check the notification is arrived until APNS?
Thanks for reading my long description.
There were no errors in IOS and rails code.
I have took a code signing in ios and created a pem file by the url.
https://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
I got an error when following the github tutorial.
Thanks.

rpush APNS notifications not working

I can't seem to figure out why my apple push notifications aren't working. My sandbox and production certificates are good until mid 2016. They were working at one point. When my app went live though, I noticed that they were not working.
On the server side, where I trigger the push notifications upon a user answering another users question, I am doing everything correctly still. Retrieving the device token from my DB, etc.
def send_notification(question_user, answer_user, alert, sound, data)
if question_user && answer_user
rememeber_tokens_for_user = RememberToken.where("user_id = ?", question_user.id)
if rememeber_tokens_for_user.size > 0
rememeber_tokens_for_user.each do |remember_token|
n = Rpush::Apns::Notification.new
n.app = Rpush::Apns::App.find_by_name("Roto Forum")
n.device_token = remember_token.device_token
n.alert = alert
n.badge = unread_answers_count_for_user_id(question_user.id)
n.sound = sound
n.data = data
n.save
end
Rpush.embed
end
end
end
However, no users end up with push notifications. I'm not sure where to start debugging this. It's on heroku. Does rpush supply some sort of logs, and if so, how would I obtain these from heroku? Does rpush have a table full of notifications in pending or sent/failed state? What's the best way to debug this?

Azure Notification Hub: notifications not showing up if sent to group

I have a trouble making notification hub to work.
If I send notification to tag that has only one registration associated with it, then everything's fine. Here's source:
var alert = "{\"aps\":{\"alert\":\"some message(targeted)\"},\"inAppMessage\": \"text\"}";
hub.SendAppleNativeNotificationAsync(alert,"mytag").ContinueWith(t => {
var outcome = t.Result;
Console.WriteLine(outcome);
});
But if I try to sent my notification to all users, like so:
var alert = "{\"aps\":{\"alert\":\"some message(all users)\"},\"inAppMessage\": \"text\"}";
hub.SendAppleNativeNotificationAsync(alert).ContinueWith(t => {
var outcome = t.Result;
Console.WriteLine(outcome);
});
then no one gets the notification. I checked monitor in Azure portal but there were no errors present.
Do you guys have some ideas?
Behavior you described is incorrect. There is one known issue which can potentially cause such kind of errors for Apple only:
If some registrations in the Notification Hub have invalid device token (it typically happens when application switches from test APNS to production or if some fake tokens were used during testing in emulator) then APNS terminates connection during the send and all notifications being sent after that using same connection are just ignored. Right now Notification Hub does not handle this situation correctly.
Way to fix - clean up "bad" registrations. If you are about developing/testing and it is not critical to lose the data - just remove all the registrations. If you have a lot of existing users then email me and we will try to find solution for your particular case.
I had same issue and I tried to set true EnableTestSend property, but no luck. Then I just removed the tags while send notifications. It worked like charm.
NotificationOutcome outcome = null;
var alert = "{\"aps\":{\"alert\":\"" + "From " + user + ": " + message + "\",\"sound\":\"default\"}}";
outcome = await Notifications.Instance.Hub.SendAppleNativeNotificationAsync(alert);

Resources