Giter Site home page Giter Site logo

Comments (14)

calonso avatar calonso commented on August 29, 2024

Hi @saademou first of all I'm so glad that the gem is being useful for you. About the issue you mention I'm not really sure what may be happening, I've never heard of it before but I'd advise you to double check you're not generating multiple notifications, and if that's not the case then I'm afraid you'll have to debug inside the inner ruby-push-notifications gem to see if it is actually doing two submissions to the APNS service.

Anyway I'm happy to support you on whatever you may need during this troubleshooting process.

Regards

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

hi @calonso thanks for your answer. here the implementation of the notification part on the server side :

t = Thread.new do
		begin
		app_type = RailsPushNotifications::APNSApp.find_by(apns_app: destination[:mob_identity])
		if !app_type.blank?
		   notification = app_type.notifications.create(destinations: [destination[:token]], data: { aps: { alert: data, sound: "#{sound}.wav", badge: 1 } })
			arr_result = app_type.push_notifications
			arr_result.each do |result|
				if result.success == 1
                                   Rails.logger.info "[JOBS][ApnsJob] [perform] APNS notification has been sent "
				else
				  Rails.logger.error "[JOBS][ApnsJob] [perform] APNS notification has not been sent"
				end
			end
			else
				Rails.logger.error "[JOBS][ApnsJob] [perform] APNS APP is null "
			end
		rescue Exception => e
			Rails.logger.error "#{e.message} \n".concat( e.backtrace.to_sentence(words_connector: "\n", last_word_connector: "\n") ).concat("\n\n")
			error_catch = true
		end
	end

Can you tell me what's going wrong in my code plz

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

TBH, that looks quite right. It is also quite a long time since I last worked with this product so I'm a bit rusty as well.

A couple of questions come to me right now.

  1. Has this always happened?
  2. Can you please check that the destinations are not repeated? I mean, the only thing I can think of right now is that the destinations array is actually repeating the tokens and that's why more than one notification is reaching the phone. It would make even more sense if the notification's contents are actually equal.

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

Thanks again :)

So i investigated my code, it happens only when i have more than 5 devices to notify.

In fact, looking the Notifications in the Database by doing :

RailsPushNotifications::Notification.where(success:nil, failed:nil)

it returns some x records, Is it normal ?

Does notification stay frozen until a new push_notifications

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Well, that could definitely lead to some notifications being sent several times. A notification is pushed if sent = false, and that flag, as success and failed values are based on the results values as you can see here so that may mean that there is an issue with those callbacks, but on the other hand, that would happen with all notification types, not just iOS ones...

Coming back to my questions...Has this happened since the very beginning?

And yes, notifications are updated when push_notifications is invoked. Are the notifications that you can see in your db unsent expected to be unsent? Those ones may lead us somewhere...

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

Indeed, i am testing your gem only on iOS devices.

Has this happened since the very beginning?

1- The gem works fine when I send a single notification to the device, it receives it

2- On the other hand, when I send several notifications, some will be sent and some will remain blocked until the arrival of a new notification system. So Customers will receive old and new notifications, which creates a confusion for them by thinking that these are the same notifications

All the notifications must be sended to devices

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Well... This sounds definitely as a bug. Can you please debug if the results value assigned here is nil for the notifications that remain 'blocked'? (i.e.) to_send[i].results is nil for all but the first element.

I think that would explain the behaviour you're seeing.

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

I will debug the results and keep u in touch.

Is it possible to send a single notification without calling push_notifications.

What i need To do is to create a notification and send it immedialty. Dont care about old pending ones

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Cool, thanks for your effort!!

Yes, you can create and send the notification straight away. See this example in my rails push notifications test app

Please, let me know the outcome of your debug.

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

I saw and understood your examples. You use push_notifications all the time, it will push all pending notifications. I need to push only one ( single one )

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Ok, got you.

So you can tell the pusher to push only one by providing only the notification you're interested in. Here you can see how it normally does to push all of them, so you can do the same but instead of for all the pending ones, just for the one you want

from rails-push-notifications.

saademou avatar saademou commented on August 29, 2024

Thanks again :)

I found this link

https://github.com/calonso/ruby-push-notifications/blob/master/examples/apns.rb

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Hi @saademou.

How are you doing with this? Did you manage to find the error?

Regards

from rails-push-notifications.

calonso avatar calonso commented on August 29, 2024

Closing as stale... Please reopen if needed or add more info to the issue if you found anything interesting.

from rails-push-notifications.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.