Search code examples
iosxcodecordovasalesforcehybrid-mobile-app

SFLoginViewController not found in Cordova based Salesforce Hybrid apps?


I am a little new to Salesforce Hybrid app.

Recently, I updated the Salesforce mobile SDK.

But, When running on IOS simulator, an additional Navigation bar for changing servers was added by the Salesforce Mobile SDK.

I want to remove that bar.

What I tried:

I tried the steps described in the following link

https://developer.salesforce.com/docs/atlas.en-us.noversion.mobile_sdk.meta/mobile_sdk/oauth_hide_gear_icon.htm

But, this gives me an error:

Receiver 'SFLoginViewController' for class message is a forward declaration

Any Help is appretiated

Thanks in advance


Solution

  • There is a property to hide navigation bar and settings button within "SFLoginViewController"

    You need to write below code in init method in your main appDelegate.m file, you may have to add init the method if it is not there.

    [[SFLoginViewController sharedInstance] setShowSettingsIcon:FALSE];
    [[SFLoginViewController sharedInstance] setShowNavbar:NO];
    

    Don't forget to import "SFLoginViewController.h" in appDelegate.m

    But now as you have mentioned that "SFLoginViewController.h" is not available in your project, Simply you can create new file with name SFLoginViewController and add below code in that file:

    /** The Salesforce login screen view.
     */
    @interface SFLoginViewController : UIViewController
    
    /** Returns a shared singleton of `SFLoginViewController` class.
     */
    +(_Nonnull instancetype)sharedInstance;
    
    /**
     * Outlet to the OAuth web view.
     */
    @property (nonatomic, strong, nullable) IBOutlet UIView* oauthView;
    
    /** Specify the font to use for navigation bar header text.*/
    @property (nonatomic, strong, nullable) UIFont * navBarFont;
    
    /** Specify the text color to use for navigation bar header text. */
    @property (nonatomic, strong, nullable) UIColor * navBarTextColor;
    
    /** Specify navigation bar color. This color will be used by the login view header.
     */
    @property (nonatomic, strong, nullable) UIColor *navBarColor;
    
    /** Specify visibility of nav bar. This property will be used to hide/show the nav bar*/
    @property (nonatomic) BOOL showNavbar;
    
    /** Specifiy the visibility of the settings icon. This property will be used to hide/show the settings icon*/
    @property (nonatomic) BOOL showSettingsIcon;
    
    /** Applies the view's style attributes to the given navigation bar.
     @param navigationBar The navigation bar that the style is applied to.
     */
    - (void)styleNavigationBar:(nullable UINavigationBar *)navigationBar;
    @end
    

    Hope this helps!