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.