Jspatch to update bugs appearing in apps that are already online (super verbose)

Source: Internet
Author: User
Tags asymmetric encryption

Jspatch to update bugs appearing in apps that are already online (super verbose)words 2858 Read 422 comments What is the role of Jspatch? In a nutshell: (There are specific steps and errors that occur during the operation) the 1.iOS app shelves to AppStore needs to wait for Apple's review, which typically takes 1-2 weeks. Although the program is tested by testers before it is put on the shelves, But sometimes there will be a new version after the launch of a serious bug, resulting in the user just upgrade to the new version of the crash, serious impact on the user experience. 2. At this time can do is to quickly fix the bug and then submit to wait for a lengthy appstore audit, and then hope that the user quickly upgrade, In order to complete this bug fix, and easily lead to user churn, which is very serious to the enterprise. 3. In order to resolve the new version of the program due to AppStore audit is slow, there are 2 ways to fix the online bug in real time:

1?? Directly using UIWebView to load the HTML code on the network, so that if there is a problem only need to update the server's HTML file, the user re-enter the program, load the new HTML file, the entire program can be updated. Very small impact on users

2?? Dynamic invocation of OC via runtime using other scripting languages

1??. 1?? Waxpatch: It combines the Lua scripting language and the native OBJECTIVE-C application programming Interface (API) to invoke OC via LUA scripts.

1??. 2?? Jspatch:js is called by Javascriptcore.framework Runtime, to implement JS call OC

Jspatch Advantages:

1?? JS than Lua in the field of application development has a broader application, the current front-end development and front-end development has a convergence trend, as an extended scripting language, JS is the perfect choice

2?? Jspatch is more in line with Apple's rules. IOS Developer Program License Agreement 3.3.2 mentions that executable code cannot be issued dynamically, except for code executed by Apple Javascriptcore.framework or WebKit, JS is executed by javascriptcore.framework

3?? Use the system's built-in javascriptcore.framework, no embedded scripting engine, compact size

4?? Block support

Jspatch Disadvantages:

1?? The disadvantage with respect to Waxpatch,jspatch is that iOS6 is not supported because javascriptcore.framework is required to be introduced

2?? In addition, the current memory usage will be higher than wax, continuous improvement

Risk: Jspatch allows the scripting language to get the ability to invoke all native OC methods, unlike web front-end capabilities that are limited to browsers, with some security risks

1?? If in the network transmission process in the text JS, may be the middleman to tamper with JS script, execute any method, steal information about the app, endanger user information and app

2?? If the download after the JS save is not encrypted locally, on the jailbroken machine users can also manually replace or tamper with the script

Risk Control:

1?? Jspatch script Execution permission is very high, if in the transmission process by the middleman tampering, will bring a great security problem, in order to prevent this situation, in the transmission process of the JS file RSA signature Encryption, the process is as follows:

Server: Calculate JS file MD5 value. The RSA private key is used to encrypt the MD5 value, which is sent to the client with the JS file.

Client: Get encrypted data, decrypt the MD5 value with RSA public key. Computes the MD5 value of the JS file returned locally. Compare the above two MD5 values, if the parity is verified by, take the JS file to save to local.

Because RSA is asymmetric encryption, in the absence of the private key, the third party cannot encrypt the corresponding MD5 value, can not forge the JS file, eliminate the JS file in the transmission process was tampered with possible.

2?? Local storage

Locally stored scripts have a much smaller chance of tampering, only a bit of a risk on the jailbreak machine, and this Jspatch SDK also makes simple symmetric encryption when the script is downloaded to local, and decrypts each time it is read.

Jspatch requires users to have a background can be issued and management scripts, and need to deal with transport security and other deployment work, Jspatch platform to help you do these things, provide script background hosting, version management, ensure transport security and other functions, so you do not need to set up a background, do not care about deployment operations, Simply introduce an SDK to use Jspatch immediately.

What is the speed and stability of the Jspatch platform?

The script files uploaded through the Jspatch platform will be saved on the seven Cow cloud storage, the client app only communicates with seven cattle servers, supports high concurrency, and the CDN distributes nationwide, speed and stability are guaranteed.

In addition to the repair Bug,jspatch can also be used for dynamic operation, real-time modification of online app behavior, or dynamic add features.

Jspatch detailed documentation See GitHub Wiki

The first step: Create your own project

#import "ViewController.h"

@interfaceViewController ()

@property (nonatomic,weak) uitableview*table;

Create a mutable array to update the data

@property (Nonatomic,strong) Nsmutablearray*dataarray;

@end

@implementationViewController

#pragma mark-Lazy load variable array

-(nsmutablearray*) DataArray

{

if (_dataarray==nil)

{

_dataarray= [Nsmutablearrayarray];

[_dataarrayaddobjectsfromarray:@[@ "Huangfang--1", @ "huangfang--2", @ "huangfang--3", @ "huangfang--4", @ " Huangfang--5 "];

}

Return_dataarray;

}

-(void) viewdidload

{

[Superviewdidload];

self.view.backgroundcolor= [Uicolorgraycolor];

[Selfsetupvcwithcontent];

}

#pragma mark-Sets the contents of the controller

-(void) setupvcwithcontent

{

//Custom navigation bar title control

Uilabel* label = [[Uilabelalloc]initwithframe:cgrectmake (0,0,100,44)];

[email protected] "hfjspatch";

Label.textcolor= [Uicolorgreencolor];

Label.font= [uifontboldsystemfontofsize:30];

Self.navigationitem.titleview= label;

//Customize the item on the right side of the navigation bar

Uibutton*button =[uibuttonbuttonwithtype:uibuttontypecontactadd];

[buttonaddtarget:selfaction: @selector (AddData) forcontrolevents:uicontroleventtouchupinside];

Uibarbuttonitem*rightbutton = [[Uibarbuttonitemalloc]initwithcustomview:button];

Self.navigationitem.rightbarbuttonitem= Rightbutton;

Uitableview*table = [[Uitableviewalloc]initwithframe:self.view.bounds];

Self.table= table;

Table.datasource=self;

[self.viewaddSubview:table];

}

#pragma mark-How to add data

-(void) AddData

{

Nsstring*datas =nil;

[Self.dataArrayaddObject:datas];

[Self.tablereloaddata];

}

#pragma mark-Data source methods

-(Nsinteger) TableView: (uitableview*) TableView numberofrowsinsection: (nsinteger) Section

{

Returnself.dataArray.count;

}

-(uitableviewcell*) TableView: (uitableview*) TableView Cellforrowatindexpath: (nsindexpath*) Indexpath

{

Staticnsstring*id [email protected] "Hfcell";

Uitableviewcell*cell = [Tableviewdequeuereusablecellwithidentifier:id];

if (cell ==nil)

{

cell = [[Uitableviewcellalloc]initwithstyle:uitableviewcellstyledefaultreuseidentifier:id];

cell.textlabel.textcolor= [Uicolorredcolor];

Cell.textlabel.textalignment=nstextalignmentcenter;

cell.textlabel.font= [uifontsystemfontofsize:20];

if (indexpath.row>5)

{

cell.textlabel.textcolor= [Uicolororangecolor];

Cell.textlabel.textalignment=nstextalignmentright;

cell.textlabel.font= [uifontboldsystemfontofsize:25];

}

}

Cell.textlabel.text=self.dataarray[indexpath.row];

Returncell;

}

@end

The second step: login http://jspatch.com This website, here need to register the account ha (already have an account, you can directly login)

Download SDK to Local

Step three: Once the download is complete, open the project we have created and drag the downloaded SDK to our project.

Fourth step: Need to add two frames (LIBZ.TBD and javascriptcore.framework) to our project

Fifth step: Create an empty file (Main.js) in Project engineering, this is needless to say, everyone will ha ^_^ Note: If you want to display the JavaScript format in an empty file, you can do it:

1, first select the Created (main.js)

2.

3. Writing code in a file

Main.js

Specify the corresponding controller to update

DefineClass ("Viewcontroller", {

Add or modify a method (

Adddata:function () {

Gets the variable array in the Controller

var datas = Self.dataarray ();

Datas.addobject ("Huangfang6");

Datas.addobject ("Huangfang7");

Datas.addobject ("Huangfang8");

Datas.addobject ("Huangfang9");

If the addition succeeds, the first element in the array will be printed (this can be printed as needed)

Console.log (Datas.firstobject ());

If the addition succeeds, the first element in the array will be printed out

Console.log (Datas.lastobject ());

Self.table (). Reloaddata ();

}

})

Note: The addData in the above adddata:function () will be the same as the click button in our project, if not the same would be an error


4, in our project to find the APPDELEGATE.M file, in the following method to add a line of test code, we first test it locally to see if the success

#import "AppDelegate.h"

#import "ViewController.h"

#import <JSPatch/JSPatch.h>

@interface Appdelegate ()

@end

@implementation Appdelegate

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

{

Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds];

Viewcontroller *VC = [[Viewcontroller alloc]init];

Vc.view.backgroundColor = [Uicolor Magentacolor];

Uinavigationcontroller *nav = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC];

Self.window.rootViewController = nav;

[Self.window Makekeywindow];

[Jspatch Testscriptinbundle];

return YES;

}

@end

The following is the three of the right-aligned results after clicking +

Sixth step: Next, we need to add our Main.js file to the server to do the operation: 1, the Project project in the Main.js file project removed, before the removal of a copy out, convenient etc will be main.js file upload to the server ha 2. Log in to the previously logged-in Web site and do the following: 2.1 Add the project name we want to update: Xgjspatch

2.2 Click Add app, the following interface appears, after filling out, directly click the "Submit" button will be

2.3 Next you will see the following interface:

2.4 Click on "Add App version" to enter the following screen

Click to go to the next screen

Seventh Step: Write the following code in the APPDELEGATE.M file:

After everything is ready, you can run a few errors that may occur directly

ATS: Security mechanism Add the following code in the Info.plist

If there is no error, after the successful operation of the interface such as:

I re-changed the data and added the patch to run the results.

Jspatch to update bugs appearing in apps that are already online (super verbose)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.