Overview
Now a day to make app more popular developer has to generate virtual money management in the app in various events of application so that various features of app becomes popular by giving coins for the various events.Using this money developer gives right to convert this virtual money into real money of user can make purcheasing in various app features.Instead of this mecahnism developer can promote various third party apps in his application with the help of this powerful framework and user of his application is able to install,share and refer to these third part applications
Sometimes in an application developer required to implement some condition on the basis of some events and its associated actions.So on the basis of sucess and failure of these actions app has to generate some condition like informing the user via toast,prompt and push notiifcations and for increase more engagement in the app developer has to give some credits so that app user gives maximum enagement in the app.In any app there are varienty of customs events so to implement these events megoevent framework is very useful like giving credits when a user scored some score in the application.
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.
MegoEvents demo architecture
MegoEvents Demo app contains five main activities: SplashActivity handles the intializes logo delay which around 5 Second,MainActivity shows the effects catagories option whether is from camera and Gallery , PhotoActivity this activity apply different Effects on the images whether it is Capture from Camera or from Gallery,Help it is showing basic help content of app.
Aside from basic functinality we had integrate our MegoGrid Api in differnt section of application
- SplashActivity: Initializes the MeGoGrid Main authentication Engine through application Id,Client Id and Secret Key which which megoGrid Server Identify application.
- MainActivity: Intialize the instance of Actionsdk for fetching various application"s custom events which configured in MegoGrid CMS.
- PhotoActivity: In this we invokes the Action sdk on two events event one is photo capture event and other is gallery capture events.
Getting Started
Authorization
To use the MegoEvents SDK first of all you need to authenticate your application/device with our server. So to authenticate your application/device use the Authentication-Layer SDK and call the below mentioned code in your app launcher Activity. Integrating Authorization SDK in your IOS app
Inside the application:didFinishLaunchingWithOptions method of your appDelegate class configure MegoAuth SDK .
ActionSdkInitializer *actionSdkInitializer=[[ActionSdkInitializer alloc] init];
[actionSdkInitializer initializeSdkAction];
MegoAuthenticate *megoAuthenticate=[[MegoAuthenticate alloc] init];
[megoAuthenticate initializeMego];
|
Events
Events is an action which is trigger by an application user.it could be completed a game level or acces any feature and many more.So in event is constitute following entities which makes an event
- Event id: a unique id which represent a unique application event.So one you create any event is MegoGrid CMS u got a id for that event
- Event Tag: Some event required properties which constitute event.These custom properties is known as Tags like if you want to intergate an event e.g when a user complete a game level with some score and life remaning he/she should be rewarded with push notiifation and rewards.in this scnerio game level and user"s life are tags
- Tagid: a unique id which represent a unique event"s tag.So one you create any event is MegoGrid CMS u got a id for that tag
Tag Type: Each tags has two types.
- Persistent Some time some properties are persistable for some period like in an event id a user score a particular in a day.these type of tags are persistable and these persistable will added in the sdk for each session of game level completion event.So these type of tags are known as persistable tags
- NonPersistent Some time some properties never required persistable for particular period.Thses type of properties are known as non persistable
Tag Value: Each tags have three type of value.
- Integer: integers required for holding integer value.
- String: strings required for holding string value.
- Boolean: boolean required for holding boolean value.
Rules
Event are nothing untill they associate with rules.Basically rule is combination of events and apply actions on it like push notiifcation and Rewards prompt.So each rule in sdk constitue of following properties :
- Events: for creating a rule you need atleast one event and combinations of events.So to creating a rule you must required multiple events which constitute a rule.
- Created Tags: when a event is created there is multiple properties associated with but when we converting this event into rule we required some of its properties for creating rule.So by created tag we associate those tags which is required for that rule.
- Game level: The level of that particular game.
- Game Score: Score of user at that time.
- Game Life: Life remains on that particular game level.
- System Tags: Each event has multiple pre defined actions.In MegoGrid we have some predefined System tags which are actions for that particular event like Complete,Not Complete,Failed etc.So when we are creating a rule we have to add some system tags for the event associated with that rule.
- Value: As we have defined Tag value which is integer,boolean and String .So on creation of rule we have to give value for those tag which are associated with tag.
- TimePeriod: Some time we required event on particular time period like in particular month period.So by using this we had start time and End time for that event.
- Near Me: This flag helps us to target a particular event in particular geographical location.So by using this flag we can configure our rules for a particular region.
e.g a game level completion has following event tag.
So when we creating a rule for user who had completed that game level having a certain score.So we need Game level and Game Score.So on the creation of that rule we need those two tagsd as Creted tag.
Rules Actions
For any Rule developer will choose action on particular rule .As in MegoEvent CMS there are two types of events as below
- Either Rewarding user with prompt,toast and none.For Detailed refer to MegoRewards Tutorial.
- Generate Push notification which is standard,Rich and Prompt.For Detailed refer to MegoPush Tutorial.
Creating Event in SDK
As in this demo app we have created Events when a user capture images from camera and apply effect on it.
In this demo app we have two events
- capturing picture from camera and applying effect on it.
- capturing picture from gallery and applying effect on it
So we have create two events and for these events we have two events ids and we have two rules when user capture images from camera/gallery and applying effect on it.These are event ids which is generated by MegoEvent cms
public static final String CAMERA_EVENT=“PJYDOH1GJ”; public static final String GALLERY_EVENT=“EIV5FOOO0”;
For integrate rules in MegoEvent sdk we have three steps
- Create ActionPerformer instance.
- Building EventBuilder instance for events and action.
- Passing EventBuilder instance to action performer instance.
1)Create ActionPerformer instance:-First we have to create ActionPerformer instnance for each event whose rules is constitutes.As we have done this in demo application.
In this demo app we have integrate in PhotoActivity applyEffect method as:
MAActionPerformer *mAActionPerformer=[MAActionPerformer sharedActionManager];
|
2)Next we have to create Event Builder instance.As in our demo we have two event ids and one action then we have to create below code
if(type_click==Constant.CAMERA_EFEECT) { NSMutableDictionary *dictionary =[[NSMutableDictionary alloc] init]; [mAActionPerformer onActionPerformed:Constant.CAMERA_EFEECT status:@“Complete” Dictionary:dictionary]; } else { NSMutableDictionary *dictionary =[[NSMutableDictionary alloc] init]; [mAActionPerformer onActionPerformed:Constants.GALLERY_EVENT status:@“Complete” Dictionary:dictionary]; } |