Judith is developing a plugin, discourse-app-notifications, to enable push notifications for Discourse installations via a custom app, particularly for iOS. She encounters an intermittent ‘plugin not found’ error when users attempt to subscribe or unsubscribe via the app, but the issue resolves after force-quitting and retrying. The error occurs despite no changes to the Discourse installation. Merefield suggests refactoring the plugin to follow Zeitwerk standards and placing the controller in app/controllers, while pfaffman notes that using PLUGIN_NAME in the requires_plugin line may help. Judith initially used the Pushover Notifications plugin as a foundation, which led to an unconventional structure. After rewriting the plugin according to guidelines, the issue is resolved, and she has released a new version at https://github.com/Sprachprofi/discourse-fcm-notificationsJudith, merefield, pfaffman, Judith, pfaffman, Judith, pfaffman.
My problem is that when someone installs the app, logs in and then goes to copy-paste their device key, it doesn’t work, Discourse yields “required plugin ‘discourse_app_notifications’ not found” for the POST /app_notifications/subscribe action (and same for the unsubscribe action). However, when the same person force-quits the app and then does the same step again, there is no error message and the push notifications do work.
What could possibly cause Discourse to recognize the plugin in one case and not recognize it in the other case, when the same call is made from within the app? No changes have been made on the Discourse installation in the meantime and this behaviour is consistent and reproducible.
I had a similar problem (though it seemed to be warning and not an error), but making my line like this:
use the PLUGIN_NAME seems to have fixed it.
Like Robert said, it might fix some things if you put your controller in app/controllers rather than in plugin.rb. I too was confused where it might be.
I do have requires_plugin DiscourseAppNotifications::PLUGIN_NAME, so I’m not sure which change you’re suggesting, if any?
The reason the plugin is structured like this is because I used the Pushover Notifications plugin as a foundation rather than coding from scratch. It’s my first plugin and due to the interaction with the app it’s notoriously difficult to debug, so I was hoping to avoid some bugs this way…
No. It s mostly a shrug. I had the problem, but you seem to have done what I did to fix it.
Sounds like what I would have done.
Rails is really picky about a bunch of things. I didn’t know it would let you put that stuff in plugin.rb. And I don’t know if moving stuff to a bunch of different places will fix it. Sorry.