I have a requirement where I want to send push notifications to the user.
For example
the app will have 2 users. If user 1 send a friend request to user 2
then user 2 should get a notification like " You got friend request
from user 1" and when user 2 clicks on that notification he should
able to see the user 1 profile.
I know how to do all these with the activities but here I am using web view, so please help me to solve with this. Any help is appreciable.
You can always access your Java code trough javascrtipt running on the web page your WebView is presenting. You can define a Java method (which sends the notification through your backend) and call it from your custom javascript.
Take a look at https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,%20java.lang.String)
Related
I am building an react-native app. I have a background android service that receives a push notification. I need to store the notification information(title, description...) on a react-native database or in asyncstorage... because in my app I have a page that shows all the notifications. I need that If my app is on background and i receive a notification, when the user open the app the page shows this information. How I can do this?
I try to store the notification on the same database that react-native uses but I can't store the data on the android service. Please, help me.
Did you try exploring these.
componentWillMount() {
Linking.addEventListener("url", this.handleOpenURL);
OneSignal.addEventListener("ids", this.onIds);
OneSignal.addEventListener("received", this.onReceived);
OneSignal.addEventListener("opened", this.onOpened);
}
And in oneReceived event listener you can store data in async storage received from push notification.
onReceived(data) {
this.props.setData(data);
}
In set data you can have your logics to store data.Well i must say push notifications are not used to fetch data and to store and then to render.These provide just little information to open specific screen .Like i received a notification related to deals.Then pressing upon will automatically opens deals screen through linking not the home page of app.For your case you can send the request on that specific page to fetch data.
Yes, but when you close the app and after this, someone sends one push notification, the event received and opened etc don't do nothing. I tried to make a custom native module that receives this info and try to send an Event. I followed this guide:
https://facebook.github.io/react-native/docs/native-modules-android#sending-events-to-javascript
But it don't works, always returns "sendEvent called before bundle loaded" java.lang.NullPointerException.
I want to send mail on click of a button without opening mail application using IONIC only. Is this possible in IOS and ANDROID? I have used email composer but it opens mail application.
So the logic here is that it would be actually pretty bad (for users) if mobile apps / web-apps would gain ability to send emails without user's explicit action to do so. Think of spam bot networks that would emerge etc.
You have 2 options:
create your own server side logic (API) that clients call to and
perform email action via an "email as a service".
help user to open email client with "pre-filled" email details
For #1 you can use sendgrid.com and similar services, so that your own service could call sendgrid and dispatch emails/
For #2 there are simple web techniques (not ideal though) like so:
submitIdea() {
let formattedBody = `Hi, here is my idea...: \n \n \n`;
window.location.href = `mailto:ideas#yourdomain.com?subject=Idea for web app from ${this.foundation.userData.user.nickname}&body=`+encodeURIComponent(formattedBody);
this.foundation.analytics.track("idea", "user clicked submit button");
};
This will open app default email client and will help user to type less of text or supply certain app details automatically.
I used this to help with user support / feedback type of emails, where app version etc context can be auto populated.
I have created a webview app which working is perfectly fine with a website say xyz.com
The app is made for small scale purpose and for personal use. (Not uploaded in play store)
Generally when I change some content in the website - Index.html(say) the app also gets update as it loads the updated url.
I want to create a notification that whenever I change the content user gets a notification in their notification bar say (today event - abc ) and when they click that notification it opens the app to see what got updated.
How to create such notifications?
You need to first register your user and get the gcm registration id and save it on your server. Then you can implement notification system present in android like this http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Whenever you change your content just send a notification to all the user base and your work is done. Thanks
You can add bootstrap modal in index.html page. and add content on that model
We've had to code an OTP based authentication. I have seen some apps, like my bank's app, which when it sends the OTP also then immediately does a quick popup of the SMS that has just arrived, so I can see the OTP without leaving the app. I just memorize the number, close the popup, and get on with the login inside that app.
How do they do that? Is there some iOS/Android spec I should be looking at, which allows us to similarly popup the OTP without the user having to go to the SMS screen, then come back to our app? Thanks!
EDIT: I have very useful Android suggestions. Now looking for iOS variations of these recommendations. Understand iOS has much more stringent sandboxing limitations, so the "listener" may be more complex?
For android you need to use SMSListener as pointed out by #rushabh.
You can check at a great example here
Some Tips to achieve your mention task for your App.
Step - 1 create a Login Activity with necessary field like username , password and otp and Login Button.
Step - 2 When user fill the username and password make a web service call. with input params (username and password)
authenticate the values if true means send your OTP number as response else response error message.
Step -3 if response is number means create AlertBuilder for Pop window to show your OTP number in same Activity.
Step - 4 user saw the OTP in Login Activity itself and enters the OTP in opt area i.e (EditText).
Step - 5 When user tap the login Button authenticate the OTP value. and proceed to next Activity.
This may be a noob question in Android porgramming but here goes..
I have an apk setup on my website as a link to say www.manusandme.com/test.apk. I would like to capture this website address on which the link is and display it to the user once the app is installed and opened for the first time.
Say once the user installs app and opens it for the first time, on the home screen it displays. Hi, you just got this app from www.manusandme.com. instead of say Hello World!
User goes to site ----> Clicks on link ---> APK is downloaded to phone ---> User installs it ---> THen user opens it ----> Message with website on which user clicked needs to be displayed on home screen.
Is this possible in android? Kindly advise.
Thanks in advance for your help.
With regards,
Manus
Yes, You can save in you SharedPreferences some flag informing that this message was already shown. For example in you main activity do this:
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean wasShown = preferences.getBoolean(Const.Config.MESSAGE_WAS_SHOWN, false);
then if wasShown is false, then show your message and after showing it update this preference to true.
Hi yes its possible to pass the website url with the parameter attached with its url.
for example :www.your_url.com/Firsttimeapp/IMEI_no=122412342355345
And create a separate catching on the website that only add's the New IMEI no of the mobile.
The Problem with the shared preference will that once any clear's the app data it will again send an entry on the server side.