Integrate the report mobile client into your mobile app [IOS, Android] And appandroid

Source: Internet
Author: User

Integrate the report mobile client into your mobile app [IOS, Android] And appandroid
Application scenarios

Users have their own apps and want to integrate the report's mobile terminal [Taking FineReport as an example] function into their apps without installing two apps. The integrated interfaces on Android and IOS are different. The following describes how to implement them separately.

IOS integrated App

1. Resource preparation

Prepare the resource files for integrating the FineReport App on IOS, including your own IOS project and the resource packages provided by FineReport.

Download the integrated resource package provided by FineReport and decompress it to the folder. You can see the file shown in:

 

Here, the FRDemo and FRDemo _ directory tree are sample demos, indicating the instructions in the folder. The remaining three folders are the resource packages required for integration.

Framework & bundle: contains the framework and bundle resource files and image resources (IFImages. xcassets) required for integration between the real machine and the simulator );

WeiXinSDK: SDK;

BaiduMap: Baidu map SDK

FRDemo: Integration example. You can set the server address, report path, and load the report to directly access the report through the URL;

FRDemo _ directory tree: Integration Example 2. You can log on to the server and display the directory tree. This is verified by sending the user name and password. After the verification is successful, the homepage or directory tree of FineReport is displayed directly.

2. Import Resources

Import the source file framework & bundle \ simulator \ FineResource in your project. bundle, add framework & bundle \ IFImages. xcassets are added to the project and the lib package shown in Build Phases -- Link Binary With Libraries is added:

 

 

FineSoft. framework is the resource file provided by FineReport. It is under the directory of framework & bundle \ real machine \ FineSoft. framework in the decompressed folder.

At the same time, add the SDK and Baidu SDK in the resource downloaded earlier in the project, such:

 

 

3. Integrated Use of FineReport App

After all resources are imported and configured, You need to integrate the App. There are two ways to integrate the App on IOS: one is to directly integrate the template on the server through the URL, in addition, the FineReport directory tree is displayed after the user name and password are sent to the server.

3.1 direct URL Integration

Directly integrate reports with URLs to directly access reports on the FineReport server through URL links.

In the project, use IFEntryViewController to load the report, and create an IFEntryViewController object based on the Report path, server path, and preview type.

Introduce header files:

1. # import <FineSoft/IFEntryViewController. h>

Generate IFEntryViewController: IFEntryViewController * entryVC = [[IFEntryViewController al-loc] initWithPath: path ServerUrl: url] based on the server address and report path:

ReportPath: Report path, such as app/DetailedDrillA-phone.cpt;

ServerUrl: server address, such as http: // 192.168.1.100: 8075/WebReport/ReportServer;

ViewType: the preview type. Optional values: IFEntryViewTypePage (paging Preview) and IFEntryViewTypeWrite (filling Preview). Optional. The default value is paging preview;

Parameters: parameters passed in the Report. Optional;

If all the above four interfaces are used, the usage is as follows:

-(Id) initWithPath :( NSString *) reportPath serverUrl :( NSString *) serverUrlviewType :( IFEntryViewType) viewType parameters :( NSDictionary *) params;

For example, if a URL is integrated with a form under an online app demo, the URL can be directly previewed without passing parameters. The Code is as follows:

1. IFEntryViewController * entryVC = [[IFEntryViewController alloc] initWithPath: @ "app/sales/orders. frm" serverUrl: @ "http://www.finereporthelp.com: 8889/app/ReportServer"];

For detailed usage, see the FRDemo example in the resource package.

3.2 integrated directory tree view Template

The integrated directory tree refers to accessing the directory tree of the system after sending the user name and password to the server for verification and viewing all templates in the system.

Use IFEntryViewController to load reports in the project.

The interface code is as follows:

· Introduce header files

1. # import <FineSoft/IFFrameUtils. h>

2. # import <FineSoft/IFFrameDirectoryViewController. h>

· Log on to the server

1. [IFFrameUtils logInto: DEFAULT_SERVERNAME serverUrl: url withUsername: username andPassword: password success: ^ {

2. // log on successfully. Load the directory tree.

3. [IFFrameUtils loadReportTree: ^ (NSMutableArray * reportsArray ){

4. // The directory tree is displayed after loading successfully.

5. IFFrameDirectoryViewController * directoryVC = [[IFFrameDirectoryViewController alloc] initWithReportsArray: reportsArray];

6. [self. navigationController presentViewController: directoryVC animated: YES comple-tion: nil];

7.} failure: ^ (NSString *){

8.}];

9.} failure: ^ (NSString *){

10.}];

Meanings of parameters for logging on to the server:

ServerName: the server name, such as the Demo server;

ServerUrl: server address, such as http: // 192.168.1.100: 8075/WebReport/ReportServer;

Username: user name;

Password: password;

Success: callback function for successful login (usually load the directory tree );

Failure: callback function for Logon failure.

The usage of each of its parameters is: + (void) logInto :( NSString *) serverNameserverUrl :( NSString *) serverUrl withUsername :( NSString *) usernameandPassword :( NSString *) password success :( void (^) () success failure :( void (^) (NSString *) failure;

For example, to integrate the directory tree of the online app demo project, the Code is as follows:

1. # import <FineSoft/IFFrameUtils. h>

2. # import <FineSoft/IFFrameDirectoryViewController. h>

3. // log on to the server

4. [IFFrameUtils logInto: @ "Demo server" serv-erUrl: @ "http://www.finereporthelp.com: 8889/app/ReportServer" withUsername: @ "demo" andPassword: @ "demo" success: ^ {

5. // log on successfully. Load the directory tree.

6. [IFFrameUtils loadReportTree: ^ (NSMutableArray * reportsArray ){

7. // The directory tree is displayed after loading successfully.

8. IFFrameDirectoryViewController * directoryVC = [[IFFrameDirectoryViewController alloc] initWithReportsArray: reportsArray];

9. [self. navigationController presentViewController: directoryVC animated: YES comple-tion: nil];

10.} failure: ^ (NSString *){

11.}];

12.} failure: ^ (NSString *){

13.}];

For detailed usage, see the FRDemo _ directory tree example in the resource package.

4. Notes

1. It must be used with FR8.0 or FR7.1.1;

2. The provided example FRDemo can only be run on a real machine. To run it on a simulator, replace the framework and bundle files in the framework & bundle/simulator;

3. If an error occurs when the c file of Baidu map is integrated, change-all_load in other linker flags to-ObjC.

5. Enable Native reports

If the integration method is triggered by an html element event on webView and the native report is opened, You need to customize WebView to inherit UIWebView and override-(BOOL) webView :( UIWebView *) webViewTshouldStartLoadWithRequest :( NSURLRequest *) requestnavigationType :( UIWebViewNavigationType) navigationType method. The principle is to analyze the url. If the url is a report type, EntryViewController is used to open the report.

The example is as follows:

1.-(BOOL) webView :( UIWebView *) webViewT shouldStartLoadWithRequest :( NSURLRequest *) request navigationType :( UIWebViewNavigationType) navigationType {

2. if (navigationType! = UIWebViewNavigationTypeLinkClicked ){

3. return YES;

4 .}

5. NSString * urlString = [[request URL] absoluteString];

6. NSMutableDictionary * urlDict = [IFFrameUtils analysisUrl: urlString];

7. if ([urlDict contain: KEY_URL]) {

8. // It indicates a common hyperchain.

9. IFWebViewController * toWebView = [[IFWebViewController alloc] initWithUrl: [urlDict objectForKey: KEY_URL];

10. toWebView. title = @ "Link ";

11. [self iFPushVC: toWebView animated: YES];

12.} else {

13. // indicates the report type hyperchain.

14. IFEntryViewType viewType = IFEntryViewTypePage;

15. if ([[urlDict objectForKey: KEY_OP] is1_tostring: KEY_VIEWTYPE_WRITE]) {

16. viewType = IFEntryViewTypeWrite;

17 .}

18. IFEntryViewController * entryVC = [[IFEntryViewController alloc] initWithPath: [urlDict objectForKey: KEY_PATH] serverUrl: [urlDict objectForKey: SERVERURL_KEY] viewType: viewType];

19. entryVC. title = urlDict [KEY_PATH];

20. [self iFPushVC: entryVC animated: YES];

21 .}

22. return NO;

23 .}

6. Test

FineReport provides a Demo address for testing.

Server address: www.finereporthelp.com: 8889/app/ReportServer;

User name: demo;

Password: demo;

Available report path:

DetailedDrillA-phone.cpt/app

Para-phone.cpt/app

DetailedDrill-pad.cpt/app

App/parapad. cpt

App/sales. frm

App/sales/map. frm

App/sales/saleseffects. frm

App/sales/TOP6-pad.frm

App/sales/product. frm

App/sales/SWOT. frm

App/sales/orders. frm

App/sales/abc. frm app/financial/FinaceStatistic. frmapp/Operations/area. frm

......

Android integrated app

1. Resource preparation

Prepare the Android project that needs to be integrated with the FineReport App and download the integrated resource package provided by FineReport.

Download the integrated resource package provided by FineReport and decompress it to obtain the following files:

 

 

Copy the extracted libs directory and res directory to the Android project that needs to be integrated, and reference the JAR package and armeabi directory under the libs directory to the Android development project as dependent libraries, for example:

 

 

2. Modify the AndroidManifest. xml file

Open the AndroidManifest. xml file in your project, and write the extracted AndroidManifest. xml file from FineReport to the configuration file in your project.

3. Integrated Use of FineReport App

The FineReport Android App provides two types of interfaces: directly using URLs to access templates on the server and integrating them into your own apps in the form of connections. The other is using directory entry integration, by verifying the user name and password, you can log on to the homepage or directory page of The FineReportApp.

3.1 directly integrate URLs

Use URL integration. directly use the URL to access the server Engineering Template. For example, if we want to integrate the WorkBook2.cpt Template under the server and fill in the template, the Code is as follows:

1. Intent intent = new Intent ();

2. intent. putExtra ("url", "http: // 192.168.100.121: 8075/WebReport/ReportServer? Reportlet = WorkBook2.cpt & op = write ");

3. intent. setClass (this, IntegrationActivity. class );

4. startActivity (intent );

Note: op = write indicates that the op parameter is in write filling mode. The preview template is normal and you do not need to add the op parameter.

3.2 use directory welcome entry Integration

Using the welcome directory integration, directly logging on to the report homepage or directory is equivalent to embedding the FineReport App into your own App. When you need to enter the FineReport App, you can log on to the homepage or directory page of The FineReportApp by sending the user name and password verification. The interface is as follows:

1. Intent welcomeIntent = new Intent (this, LoadAppFromWelcomeActivity. class );

2. welcomeIntent. putExtra ("username", "demo"); // User Name of the Data Decision Making System

3. welcomeIntent. putExtra ("password", "demo"); // user password of the Data Decision Making System

4. welcomeIntent. putExtra ("serverIp", "http://www.finereporthelp.com: 8889/app/ReportServer"); // data decision system ip Address

5. welcomeIntent. putExtra ("serverName", "demo server"); // data Decision Making System name

6. startActivity (welcomeIntent );

Note: If the home page is set in the server system, the page will jump to the home page after logon. If the home page is not set, the directory page will be displayed directly.

 

Related Article

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.