NAV

Overview

MegoUser is one of the module of MegoGrid. So here I am explaining what MegoUser is and how it works for an Ios App Developer.

Now a days , Mobile Technology is becoming too vast for the ease of the world, keeping the KISS principle (Keep It Short and Simple), Developers are doing their best to make the world Techno Freak. As their time is too precious, Frameworks are being developed to save the time. So, Every developer needs details of their application users, by which they could kept record of each and every brief detail of their user, which he/she could use accordingly.

Now I am sure, Everybody have some questions in their mind, So lets start knowing What, Why and How? about MegoUser.

MegoUser Demo is app which apply photo effects of camera images and Gallery images.This app is avalable in App Store and its source code avalable on Github.You can take all refrence of source code and how we integrate a power platform of Mego User as for authentication and backup synching.In this i represent i will guide you how we can integrate Mego User to a App and how this power framework makes Authentication mechnism so simple whether it is login from mechnism from facebook,Google SignIn and email and all this finally integrate with our powerfull megogrid Server.

This tutorial is divided into several parts, each focusing on a different aspect of our Mego Grid Demo App. Feel free to read them in any order, but we recommend that you download the source code and refer to it while reading. Some parts of the code were omitted or changed in this tutorial in order to keep it clear and concise, so you may find it useful to keep the full version close at hand.

MegoGrid demo architecture

MegoUser contains some of the helper class for photo editing effect: slideView show all the option in slide view DownloadimageHistoryViewController shows the saved images history, FlipRotate this controller apply rotate images in different direction, UIImage+Filtering and ALAssetsLibrary+CustomPhotoAlbum this two Catagories apply different Effects on the images help content of app

Aside from basic functinality we had integrate our MeGoGrid Api in differnt section of application

Getting Started

Authorization

Megogrid uses Authorization Layer for authenticating your application’s user from within the Authorization SDK. You must add Authorization SDK before using any of the Megogrid module.

Integrating Authorization SDK in your Ios app

Import the MegoAuth sdk in AppDelegate.m

#import <MegoAuth/MegoAuthenticate.h>

Create the MUManager,MegoAuthenticate class instance inside the AppDelegate interface.

@interface AppDelegate ()
{
MUManager *megoUserObj;
MegoAuthenticate *mewardAuthObj;
}

Inside the didFinishLaunchingWithOptions method of your AppDelegate.m configure MegoAuth SDK .

mewardAuthObj=[[MegoAuthenticate alloc]init];
[mewardAuthObj initializeMego];

MegoUser

The MegoGrid Demo app represents here the use of MegoUser SDK. MegoUser use the two way mechanism to the user to register his/her device/application on our server. These are as described below:

Here the second part (Email) is further divided into three sub parts which are cited as follows:

Integrating MegoUser SDK in your IOS app

Before integrating MegoUser SDK you have to configure the required details on our MegoGrid CMS Panel provided to you by us. Here you can provide the options a user of your app will have for registration of their devices/application. For example you can provide all the three Email option or either one of them to register via your app.

For this Demo App we have already configured all the detials (dummy configuration) so that you can download and check how this unique system works or you can check if it suits your developemnt need.

Below are the step by step guide how we have integrated this SDK into our Demo app inside -(void)megoUserMethod method which call inside -(void)viewDidLoad method of our viewController class

1.Call the below code inside the -(void)megoUserMethod method of your viewController class if you only want to give the custom id registration option to your app user. So user will only be prompted with the cutom registration/sign Up option.

However, if you have provided the Google Sign in and facebook registration/Sign Up to the app user then you must have to pass the GooglePlusClientId(provided to you at the time of creating google project on Google Console for Google Sign in signIn) and FacebookAppId .
login and sign up through Facebook and add following field in your info.plist file. Below is the code snippet that shows how to do this.

After above step Add Custom Url Scheme in the Info tab under the TARAGETS following way click on plus (+) icon then fill the bundle identifier in identifier field and FacebookAppId in place of URL Schemes for Facebook case and for Google add bundle identifier in both field.

image

Initial Setting in AppDelegate.m for Google and Facebook SignUp And Login case-
a) To add following framework in the AppDelegate.m

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <GoogleSignIn/GoogleSignIn.h>
#import <MegoAuth/MegoAuthenticate.h>
#import <MegoUser/MUManager.h>

b) Within AppDelegate.m in the didFinishLaunchingWithOptions method add Facebook method in the end,finally didFinishLaunchingWithOptions look below code.

First call initSDK method of MUManager class then call initializeMego method of MegoAuthenticate class like following code.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
megoUserObj =[MUManager sharedMegoManager];
  [megoUserObj initSDK];
  mewardAuthObj =[[MegoAuthenticate alloc]init];
  [mewardAuthObj initializeMego];
  [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
  return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}

c) Within AppDelegate.m UIApplicationDelegate have a method within this method we add the following code.

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation: (id)annotation
{
BOOL IsFbLogin=[MUManager getFbLoginBoolean];
if(!IsFbLogin) {
return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
else{
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
}

add MegoUser delegate (MUDelegate) in your View Controller interface

@interface ViewController()<MUDelegate>>{

}

Moreover, if you want some more customization to your registration process like providing your own theme background for all types of registration option at the time of prompt appear to the screen then just add the

megoUserObj =[MUManager sharedMegoManager];
megoUserObj.delegate=self;
megoUserObj.view=self.view;
megoUserObj.navigationController=self.navigationController;
megoUserObj.backGroundImageArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"BackGround.jpg"],[UIImage imageNamed:@"1.jpg"],nil];
megoUserObj.megoUserTitleImage=[UIImage imageNamed:@"appLogo.png"];

User Management

User Management is a way through which various mobile apps are managing their users and keep tracking shoping behaviour,health tracking,finance tracking etc.MegoUser Sdk provides a powerful way through this kind of management becomes easy.This SDK integrates your IOS app by adding logic for authentication such as login , signup and logout aside from these this powerful sdk provides various other mechanism like backup creation and back restore of user crucial data.In this demo we intoduce a way through how you can bind this mechanism in just few steps as we described below:

Sign up / Login

Once you configured all the required things for MegoUser sdk described above in MegoUser section, In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call signUpLoginPrompt method :

So after checking the configuration details from server it will decide which type of promts will appear on the User mobile screen like if user is a first time user then it will prompt for registration, if user is already registered then signIn prompt will appear. Moreover if the CMS panel is set on optional registration then after the first time app launch not prompt will comes on further launch of the application.

Apart from the above cases if there is any reason for the failed registration process then you will be notified via our MUDelegate delegate of MUManager class that will be thrown in such cases so that you can check where the loop hole is and can handle such condtion accordingly.

megoUserObj =[MUManager sharedMegoManager];
megoUserObj.delegate=self;
[megoUserObj initiateRegistration];

Calling initiateRegistration method will handle all of your Sign up / Login prompts according to your configuration set at our Megogrid CMS panel. Pass your interface for receiving Sign up / Login callbacks by MUDelegate delegate.

- (void)muRegistrationSuccessHandler{
NSLog(@“\n Login And Registration Email or Sms”);
}

if any error occurred then get response on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSError*)failureError{
NSLog(@“\n failureHandler”);
}

Logout

When you’ve got login to work, you probably want to have the option to logout. All you have to do is to call the below method on click of any event producing View. Here’s an example of a logout menu in the SlideView.m class.

In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call logoutClick method :

[megoUserObj logoutClick];

We than get the logout status in BOOL return type.

if logout is success than get the status value true, If logout fail than get the value false.

Backup

The backup service of MegoUser allows you to copy your persistent application data to a remote cloud storage. This allows you to restore the application data and settings in case the user switches IOS devices, re-installs the application . This feature also helps you to reterive your data back in case of any misshappening like loss of data, device got stolen, damage etc.

The persistent data that you want to backup is in form of NsUserDefaults. MegoUser supports NsUserDefaults data types of backup in App backup form.

Create App Backup

This will help you in backing up of all the information related to the specific app.It aims at reducing the efforts of again and again filling the same info to use the app in desired manner.

In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call createNSUserDefaultBackup method :

[megoUserObj createNSUserDefaultBackup :3];

parameter - createNSUserDefaultBackup have parameter which is NSInteger type. here is 3.only one parameter .
Here megoUserObj is the object of MUManager class.

If there is any reason for the failed backing up data process then you will be notified via our MUDelegate by the following method help :

if any error occurred then get response on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSString*)failureError{
NSLog(@“\n failureHandler”); }

Restore App Backup

This will help you in restoring all the information backed to NsUserDefaults.
In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call restoreNSUserDefaultData method :

[megoUserObj restoreNSUserDefaultData :3];

parameter - restoreNSUserDefaultData have one parameter NSInteger type. here is 3.only one parameter .
Here megoUserObj is the object of MUManager class.

If there is any reason for the failed restoring data process then you will be notified via our MUDelegate by the following method help :

if any error occurred then get response on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSString*)failureError{
NSLog(@“\n failureHandler”); }

Profile

Profile management ensures that the user’s personal settings are applied to the user’s devices and applications, regardless of the location and end point device. User can set their profile only if he/she is already registered. If he/she is a first time user of the app then he/she will be prompted with the registraion prompt.

Profile management is enabled through a profile optimization service that provides an easy, reliable way for managing these settings in IOS application to ensure a consistent experience by maintaining a single profile that follows the user. It auto-consolidates and optimizes user profiles to minimize management and storage requirements and requires minimal administration, support and infrastructure, while providing users with improved logon and logout. In this Demo app we have shown how our profile management system works with the IOS application.

Profile Setup

This will help you in viewing user’s latest profile setup screen. If user is already registered a profile setup view will be shown to the user where he can manage his demographic details and more. But if he is not registered then there will be registration prompt comes.

As part of the Profile Setup process, we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call profileSetUpClick method :

[megoUserObj profileSetUpClick];

If there is any reason for the failed profile setup process then you will be notified via our MUDelegate by the following method help :

if any error occurred then get response on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSString*)failureError{
NSLog(@“\n failureHandler”); }

Registeration Reminder

You might not force your users to register first and then use your application. But there might be some features in your application where you want your user’s credentials first before allowing access to that feature. So in this case you can use our registration reminder feature of MegoUser SDK. It will prompt user to register first before exploring inside of such features.

we might not force your users to register first, and then use our application. But there might be some action events where we want to remind our users that their registration is pending. we just have to give our buttons name at CMS panel, an auto generated boxId will be given to us.

In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call showRegisterByBox_Id method :

Lets say, a boxId provided by CMS panel.

[megoUserObj showRegisterByBox_Id :@“ KPDFC20UD ”];

parameter - showRegisterByBox_Id have only one parameter it was NSString type. here is @“ KPDFC20UD ”. KPDFC20UD is a Box Id will be given by CMS panel.

If there is any reason for the failed registration reminder process then you will be notified via our MUDelegate by the following method help :

if any other error occurred then getresponse on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSString*)failureError{
NSLog(@“\n failureHandler”); }

Verification Pending

This will help you in finding whether your user’s account email is verified or not.

In our demo app we have SlideView.m class have didSelectRowAtIndexPath delegate of tableview inside of this delegate get the callBack in viewControler class by PushToViewController and according to condition in switch case call isEmailVerified method :

To Call isEmailVerified method for Verification of User. to check is it registered and verified or not.

[megoUserObj isEmailVerified]

If there is any reason for the failed Verification process or user is not registered then you will be notified via our MUDelegate by the following method help :

if any error occurred then getresponse on megoUserErrorHandler method.

- (void)megoUserErrorHandler:(NSString*)failureError{
NSLog(@“\n failureHandler”); }

if user already registered then get response true on verificationStatus method.

-(void)verificationStatus :(BOOL)userVerified{
}





© 2015-2016 Megogrid Inc. / Term of service / Licenses / Privacy Policy 913 N Market Street Suite 200 Wilmington DE 19801 USA