I am new to pushbots and have done push notification as it given in tutorial, but when I click on Dashboard and then push it display an alert box which messaged "No devices Yet" I am not getting how to add device while I have installed apps in Android mobile.
Please help me out...
I had the same problem, and made sure more than once that everything is right
Then tried to uninstall the app and install it again with taking instance from MyApplication in my MainActivity
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new MyApplication();
}
}
And This worked for me, but when i tried again to delete the instance and delete uninstall the app it still registered on pushbots website!!
Related
I have a question. Can we add a invite button to the mobile app in android studio which on clicking gives referral link of the website instead of the application itself? Can we use firebase dynamic link for this or is it only to refer app itself?
I have added the code for dynamic link but its only to refer mobile app and not the website. I'd like to know if we can refer website as well.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_refer);
invite = findViewById(R.id.inviteBtn);
// calling the action bar
ActionBar actionBar = getSupportActionBar();
// showing the back button in action bar
actionBar.setDisplayHomeAsUpEnabled(true);
invite.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
inviteLink();
}
});
}
public void inviteLink(){
Log.e("main", "invite link");
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse("https://www.versatileva.com.au/"))
.setDomainUriPrefix("versatileva.page.link")
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
.setIosParameters(new DynamicLink.IosParameters.Builder("com.android.versatilevaproject").build())
.buildDynamicLink();
Uri dynamicLinkUri = dynamicLink.getUri();
Log.e("main", " Long refer "+ dynamicLink.getUri());
//versatileva.page.link?apn=com.android.versatilevaproject&ibi=com.android.versatilevaproject&link=https%3A%2F%2Fwww.versatileva.com.au%2F
}
}
Firebase provide this guide on rewarding user referrals using Dynamic Links. You can use Dynamic Links along with Realtime Database and Cloud Functions for Firebase to encourage your users to invite their friends by offering in-app rewards for successful referrals to both the referrer and the recipient.
How can i use broadcast receiver/intent to open flutter android app when receive firebase message.
Implment FirebaseMessagingService and start Main activity from onMessageReceived:
public class FirebaseMsgService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
//...
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
and also in MainActivity you may want to unlock device:
public class MainActivity extends FlutterActivity {
#Override
public void configureFlutterEngine(#NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}
The answer provided by #Develocode777 will work until android 9. From android 10, this behavior is not allowed anymore. You can learn more about it in this page, Restrictions on starting activities from the background.
If you are planning to show a notification, and upon clicking the notification you want to open the app, then it it will work normally, but opening the app without no user interaction, not allowed in Android 10 and above.
I have a background service in android.
My code is as follows:
[Service]
public class PeriodicService : Service
{
public override IBinder OnBind(Intent intent)
{
return null;
}
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
Device.StartTimer(TimeSpan.FromSeconds(5), () =>
{
// code
});
return StartCommandResult.Sticky;
}
}
The MainActivity class:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
StartService(new Intent(this, typeof(PeriodicService)));
}
Permission AndroidManifest.xml:
<uses-permission android:name="android.permission.PeriodicService" />
The problem is that my service only works in the background when the app is active or in the foreground but when I close the app it doesn't run in the background.
A possible solution is to follow along with what Fabio has written in his post about how to create The Never Ending Background Task.
The idea behind this is to create a BroadcastReceiver and Android Service in the manifest. The BroadcastReceiver will then activate the service with foreground priority as the application is being closed. If you are dealing with post Android 7 then he created an update to his blog showing The Fix.
Just to get a better understanding of how basic Android services operate, I'd recommend taking a look at this Android Services Tutorial
I also saw this other StackOverflow post that seems to be pretty similar so maybe there will be some useful info over there too.
I'm not too acclimated in this stuff, but I was able to follow along with the blog posts pretty easily so I hope this ends up helping :). If anyone finds a better solution I'd love to hear about it so tag be (if you would be so kind) so I can stay updated!
I am sorry, if this question is asked before, but I am unable to find my answer that is why I am asking again this question.
My Scenario is I have placed a back button on my axml views from which I am performing Navigation of Going back on previous views using GoBack() Method.
what I need I want to disable back button on my hardware so that my app should not go back to previous screens which are available in the navigation stack. I am using Prism MVVM for my app, so is there any possibility to disable this button or have some overrideable action method on my ViewModel from which I should stop it.
Hope you could understand my question.
B.R
I found the best way to do this was to use the provided override of OnBackPressed in the android MainActivity and then access a bool I saved somewhere. I use the settings plugin personally but the example below uses the built in application properties (it should work but I haven't tested it).
public class MainActivity : FormsApplicationActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Forms.Init(this, bundle);
LoadApplication(new App());
}
public override void OnBackPressed()
{
var disable = (bool) App.Current.Properties["isBackButtonDisabled"];
if (disable) return;
base.OnBackPressed();
}
}
I found there is issue with Android API 23 Toolbar implementation. Once I implemented Toolbar in my project, my device back button is not working (Android 2.3.6 Gingerbread phone). I tried switch back to Android API 21, it is working fine. Anyone has any idea how to fix Android API 23 Toolbar problem?
Thanks in advance!
EDIT: The latest version of support library (23.0.1) fixes this issue.
Fixed an issue where hardware buttons did not work when an activity
had set the Toolbar class to act as the ActionBar by using the
setSupportActionBar() method. (Issue 183334)
I have the exact same problem, but I cannot post a comment so commenting as an answer.
Some code for reference:
public class ActivitySettings extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
#Override
public void onBackPressed() {
super.onBackPressed();
Log.e("test","onBackPressed");
}
If I just remove these 2 lines, the onBackPressed gets called
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
This problem occurs only in android 2.3.x. Anything above that works fine.