last day (14 days later) » 

9:31 AM
1
A: OneSignal | Get URL from notification payload and open in custom WebView

Vamsi ChallaThe answer from SlashG, helped me. Here is my implementation... I added this code in my Application class onCreate() OneSignal.startInit(this).setNotificationOpenedHandler(new OneSignal.NotificationOpenedHandler() { @Override public void notificationOpened(OSNotificationO...

 
Hi @Vamsi Chalia, can you please tell me where did you put this code? In which file in your app?
 
I added the code in Application class on create method
 
Tnx I have found it.
But i have problems, can you help me a little bit? I have just copied it, of course it doesn't work. What do i need to change? s21.postimg.org/48p3y9xtz/image.png
 
The OSNotificationOpenResult is part of OneSignal class. See if you can import OneSignal.OSNotificationOpenResult
 
I have these imports on top: import android.os.Build; import android.webkit.WebView; import com.onesignal.OneSignal;
 
9:31 AM
Ya also do the import I said in the above comment..
 
If I do this it doesn't work
import android.os.Build;
import android.webkit.WebView;

import com.onesignal.OneSignal;
import com.onesignal.OneSignal.OSNotificationOpenResult;
 
Ok, let me paste my code here for you.. with imports and other stuff
 
are you using this in your build.gradle? compile 'com.onesignal:OneSignal:3.+@aar'
 
this is my first time that i am doing something with android and i don't have a clue... if you could show me it would be great
i have 2 build gradle files
 
9:37 AM
can you paste the dependencies section from your gradle file in app module
 
i found it
i have this
compile 'com.onesignal:OneSignal:3.4.3@aar'
should i change it to 3.+
 
Ya its the same version, but can you change it to 3.+ and see, just for testing
 
yes but i can't compile still
becuase of that photo
see above
i need to import something more
 
no, those are the only two imports.. import com.onesignal.OSNotificationOpenResult;
import com.onesignal.OneSignal;
 
oh i have a wrong input then
import com.onesignal.OneSignal.OSNotificationOpenResult;
this should be this
import com.onesignal.OSNotificationOpenResult;
 
9:41 AM
ya
let me know if that solves it
 
still errors now other stuff
 
can you paste your screenshot with new errors?
there are related to my logic, the launchURL basically will have the url that you need to show
so i think you can remove the code in if/else and write your own code there
for the Intent errors, import android.content.Intent;
 
can you help me please... i just want to open the link inside my app nothing else
 
Ya, replace the WebViewActivity, with your class name
 
i don't have a class name
:)
sorry i don't get it
 
9:46 AM
When you click on the notification, you want to open an Activity right? Use the name of the Activity there
 
i didn't create any activity....so if i understand you correctly i need to make one and make logic to open the link inside my app instead of opening the link with default smartphone browser
 
i don't know how to do that please if you could show me or teach me
 
You have lot of tutorials on that online, please search.
 
i don't want to create a new class i just want some small logic when the notification is opened if there is link open it in app
 
9:50 AM
Got to go.. happy coding
 
 
4 hours later…
1:41 PM
Can you just please tell me how to log the variable in console
how did you declare this variable DEBUG
Log.d(DEBUG, "Launch URL: " + launchURL);
 

last day (14 days later) »