Xamarin forms IOS App aksing for RootviewController - xamarin.forms

I am working on Xamarin Forms on VS 2017. Whenever I am running My IOS app it is asking for RootViewController but my other sample app is working perfectly without any exception.
My Other app has a default Implementation of Finishedlaunching. AppDelegate is inherited by FormsApplicationDelegate class
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
My main app works only after I have updated the Finishedlaunching Method. AppDelegate is inherited by UIApplicationDelegate class
UIWindow window;
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
Rg.Plugins.Popup.Popup.Init();
window = new UIWindow(UIScreen.MainScreen.Bounds);
window.RootViewController = new Login().CreateViewController();
window.MakeKeyAndVisible();
return true;
}
My question is when my other app is working fine with default code why my second application is not working and I have to add RootViewController.
Please let me know if I am missing anything.

Related

FirebasePushNotificationManager.Initialize freeze my app in iOS but no error appears

I am using Xamarin with C#.
FirebasePushNotificationManager.Initialize(options, true);
^ this code works fine in my Android Application.cs file, I can receive notifications in Android. However, when I add this code to AppDelegate.cs in iOS, it freezes my app, meaning there's no response when I click on button or input field. But if I remove this line of code, my iOS app works.
I've Googled a lot but didn't get any luck, can someone please help me?
Following is my AppDelegate.cs code:
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
ServicePointManager
.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
global::Xamarin.Forms.Forms.Init();
var iosClientHandler = new NSUrlSessionHandler();
Services.HttpClientService.HttpClientHandler = iosClientHandler;
LoadApplication(new App());
//This line is causing the issue
FirebasePushNotificationManager.Initialize(options, true);
return base.FinishedLaunching(app, options);
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
}
// To receive notifications in foreground on iOS 9 and below
// To receive notifications in background in any iOS version
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired 'till the user taps on the notification launching the application.
// If you disable method swizzling, you'll need to call this method.
// This lets FCM track message delivery and analytics, which is performed
// automatically with method swizzling enabled
FirebasePushNotificationManager.DidReceiveMessage(userInfo);
// Do your magic to handle the notification data
System.Console.WriteLine(userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}
}

xamarin.forms detect ios app entering foreground from background

I am creating app in Xamarin.Forms shared proeject. I want to detect app when it comes from background
currently, I have implemented OnActivated method in AppDelegate but this method is also called when we open control center in iphone. I want my app to reconnect with my server when app comes to foreground from background and show message accordingly but this message is also shown when I swipe up and open control center.
In native Xamarin.iOS app, there is a method WillEnterForegroundNotification but this method is not available here.
Is there any method that's called only if app comes from background ?
in App.xaml.cs
protected override void OnResume()
In native Xamarin.iOS app, there is a method
WillEnterForegroundNotification but this method is not available here.
You can access WillEnterForegroundNotification method in Xamarin.forms project, just override it in AppDelegate.cs:
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
public override void WillEnterForeground(UIApplication uiApplication)
{
//handle your event here
base.WillEnterForeground(uiApplication);
}
}

Xamarin forms : Keyboard overlap issue exist after installing keyboardoverlap plugin in IOS

I included the keyboardoverlap plugin in IOS project and added KeyboardOverlapRenderer.Init() after Xamarin.Forms.Init(); And when I focus Entry, it doesn't move up. I am not using any custom renderer for ContentPage.
What is the solution for this?
Screenshot:
My AppDelegate.cs Code: Have multiple init codes, is that affect the keyboard overlap feature?
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Rg.Plugins.Popup.Popup.Init();
global::Xamarin.Forms.Forms.Init();
KeyboardOverlapRenderer.Init();
ImageCircleRenderer.Init();
LoadApplication(new App(""));
return base.FinishedLaunching(app, options);
}

Xamarin.Forms + MvvmCross + AppCenter

I have Xamarin.Forms with MvvmCross (version 5.5) and I want to connect to AppCenter.
I tried to call AppCenter.Start on many places but when I called
bool enabled = await Distribute.IsEnabledAsync();
in app, it always return false. I tried in project without MvvmCross and it return true.
Thanks for help.
EDIT
So finally I upgraded to MvvmCross 6.0.1
in splashScreen I am calling AppCenter.Start and it worked.
public class SplashScreen : MvxFormsSplashScreenActivity<Setup, MvxApp, FormsApp>
{
protected override void RunAppStart(Bundle bundle)
{
AppCenter.Start(
"android=xxx;",
typeof(Analytics),
typeof(Crashes),
typeof(Distribute));
StartActivity(typeof(FormsApplicationActivity));
base.RunAppStart(bundle);
}
}

DataBindings are broken after update to MvvmCross 4.0 when using AppCompatActivity

I'm using the android toolbar at my MvvmCross 3.5.1 app but once I updated it to MvvmCross 4.0 databindings are broken. As long as there is no base appcompat activity I have to implement my own:
MvxActionBarEventSourceActivity : AppCompatActivity , IMvxEventSourceActivity
{
...
}
And then base bindable mvx activity:
MvxActionBarActivity : MvxActionBarEventSourceActivity, IMvxAndroidView
{
...
}
App starts just fine and I can see my toolbar but bindings are just "silent" and don't work. Same implementation works find for MvvmCross 3.5.
You can find full sample here:
https://dl.dropboxusercontent.com/u/19503836/MvvmCross4_Toolbar_Bindings.zip
Please advise.
You need to override OnCreateView and AttachBaseContext and use the MvxAppCompatActivityHelper to support bindings: https://github.com/MvvmCross/MvvmCross-AndroidSupport/blob/master/MvvmCross.Droid.Support.V7.AppCompat/MvxAppCompatActivity.cs#L78
public override View OnCreateView(View parent, string name, Context context, IAttributeSet attrs)
{
var view = MvxAppCompatActivityHelper.OnCreateView(parent, name, context, attrs);
return view ?? base.OnCreateView(parent, name, context, attrs);
}
protected override void AttachBaseContext(Context #base)
{
base.AttachBaseContext(MvxContextWrapper.Wrap(#base, this));
}
There is a sample available to implement Toolbar instead of Actionbar too: https://github.com/MvvmCross/MvvmCross-AndroidSupport/tree/master/Samples

Resources