User-to-User Interaction Using Push Notifications

Hey guys,

I am in the process of developing a utility/business app, and one of the functions of the app is give users the ability for them to interact with each other, more specifically, user sends invitation/request to meet at an X location, and the receiving user is able to accept/decline the request. The problem is, I have never worked with push notifications before, and I have no idea how to code this. I plan on using php and mysql for the push notifications.

Any help is greatly appreciated!

Are you going to use Coronium? It has it’s own push system.

Consider the OneSignal plugin. It excels at this.

If you are going to do your own, the tutorial you found will guide you with about as much advice as you’re going to find.

Is there a reason you feel you have to build this from the ground up when there are other tools in place to get you there? Building from the ground up is a great learning exercise, I’ll give it that.

I talked to Chris and from what he told me I figured it would be better to just stick with mysql and php since I already knew how to work with them. Actually I just thought I had to do it by using php since I was no longer using a backend service like coronium anymore, but I’ll take a look at the OneSignal docs, I’ll most likely be using that.

I’ll be posting again after getting myself a little more familiarized with the plugin.

Thanks!

Hey Rob,

I got everything set up with OneSignal but I dont know why I my device wont show up in the registered users in my OneSignal account. Other than the code given in the installation tutoral, is there something else to add to the main.lua file? I went through the docs and couldnt find any specific command that would register the device? There is RegisterForNotifications() which apparently is only used if you initially disabled it, I still tried it though but it didnt work.

edit: i just turned debugging on and i get warning: failed last request. statusCode: -1 response:null

and a lot of other stuff like POST Error thrown from network stack, goes on for a while

It would be really helpful for you to a) post the code you’re using (not your whole file, just the relevant bits) and b) post the content of the log.

Rob

here’s my main.lua:

-- This function gets called when the user opens a notification or one is received when the app is open and active. -- Change the code below to fit your app's needs. function DidReceiveRemoteNotification(message, additionalData, isActive) if (additionalData) then if (additionalData.discount) then native.showAlert( "Discount!", message, { "OK" } ) -- Take user to your app store elseif (additionalData.actionSelected) then -- Interactive notification button pressed native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"} ) end else native.showAlert("OneSignal Message", message, { "OK" } ) end end local OneSignal = require("plugin.OneSignal") -- Uncomment SetLogLevel to debug issues. OneSignal.SetLogLevel(4, 4) OneSignal.Init("0ecdd9b6-74c6-4115-9a6a-1f50537f7d62", "717121253104", DidReceiveRemoteNotification)

and my build.settings:

settings = { iphone = { plist= { UIBackgroundModes = {"remote-notification"}, UIApplicationExitsOnSuspend = false, UIPrerenderedIcon = true, UIStatusBarHidden = false, NSAppTransportSecurity = { NSExceptionDomains = { NSAllowsArbitraryLoads = true, ["coronalabs.com"] = { NSIncludesSubdomains = true, NSThirdPartyExceptionAllowsInsecureHTTPLoads = true }, ["youtube.com"] = { NSIncludesSubdomains = true, NSThirdPartyExceptionAllowsInsecureHTTPLoads = true }, ["google.com"] = { NSIncludesSubdomains = true, NSThirdPartyExceptionAllowsInsecureHTTPLoads = true }, }, }, }, }, orientation = { default = "portrait", supported = { "portait", "portraitUpsideDown", }, }, android = { usesPermissions = { -- Required by the MapView to fetch its contents from the Google Maps servers. "android.permission.INTERNET", -- Optional permission used to display current location via the GPS. "android.permission.ACCESS\_FINE\_LOCATION", -- Optional permission used to display current location via WiFi or cellular service. "android.permission.ACCESS\_COARSE\_LOCATION", "com.google.android.c2dm.permission.RECEIVE", }, usesFeatures = { -- If you set permissions "ACCESS\_FINE\_LOCATION" and "ACCESS\_COARSE\_LOCATION" above, -- then you may want to set up your app to not require location services as follows. -- Otherwise, devices that do not have location sevices (such as a GPS) will be unable -- to purchase this app in the app store. { name = "android.hardware.location", required = false }, { name = "android.hardware.location.gps", required = false }, { name = "android.hardware.location.network", required = false }, }, }, plugins = { ["plugin.OneSignal"] = { publisherId = "com.onesignal", }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true, ["android-kindle"]=true }, }, }, }

https://gyazo.com/686117a46b6559fe3931008c235c743b

https://gyazo.com/2936991f5bbc61fab09e8dae66bb8990

pictures of the errors

I’m going to move this to the OneSignal forum so they can help you with this.

Rob

bump

The CertPathValidatorException means that your device is missing a SSL certificate or it could be something with your network changing certificates.

Check to make sure you have “The USERTrust Network” and COMODO in your certificates under Settings>Security>Trusted credentials on Android.

Try to changing networks or remove any proxy settings.

Make sure the time and date is correct on your device.

Lastly I recommend testing on another Android device if the above does not work.

This android device i’m using doesnt allow me to check my certificates… All it says is use secure credentials and no other options. I set the right date time, still nothing though. I guess i’ll have to find another device to test on.

The Android UI looks very customized so it possible the manufacture didn’t installs all the correct certificates on the ROM for the device. You can also test with an emulator as long as it has Google Play services installed it. See the emulator note in our 2. All Users are shown as not subscribed section to make sure you get the correct setting for this.

I tried it on another device today, and it successfully registered as my first user! Thanks for the help

I now tried it on another device again, and on this one it doesn’t work. It has both the certificates on the trusted credentials too. Any ideas?

Same exact error or is it a different in anyway? Can you also check the date and time? Lastly are you using a proxy or connected to a network that maybe modifying any network traffic?

http://imgur.com/a/mXQbV album with pictures of the errors im getting.

Date and time is set right. And i am connected to a network that should be modifying network traffic, as I am connected to my universities netork, thing is, the other device i tested on (which did show up as a registered user in my onesignal account) was also in the same network, but it might possibly have been using data from the phone service provider, but i doubt it.

Thanks for the detailed screenshots, all these errors point to the Google Play services app on the device being out of date or missing on the device. See Android>Google Play services under 2. All Users are shown as not subscribed to check this and update it on the device.

I updated google play services, but im still getting the warning: "Location permission exists but there was an error intilizing: com.google.android.gms.locationServices … etc

edit: it said it was successfully registered, and it shows up in my users, but i just tried sending out a push notification and my device isnt getting it

bump

Make sure you app is in the background when you send a push notification. It won’t be shown when your app is in focus

The com.google.android.gms.locationServices won’t affect receiving push notifications. Our geotagging feature does not work for Corona on Android due to Corona’s Google Play service library being out of date.

Lastly check the logcat for any other errors or warnings when you send a push notification.

Are you going to use Coronium? It has it’s own push system.

Consider the OneSignal plugin. It excels at this.

If you are going to do your own, the tutorial you found will guide you with about as much advice as you’re going to find.

Is there a reason you feel you have to build this from the ground up when there are other tools in place to get you there? Building from the ground up is a great learning exercise, I’ll give it that.