Integrate report mobile into your own mobile app method "IOS, Android"

Source: Internet
Author: User

Application Scenarios

Users have their own app and want to integrate the mobile end of the report "Finereport Mobile as an example" into their app, without installing two apps. The integration interface between Android and iOS is not the same, we'll detail how to do this separately.

iOS-side Integration app

1. Resource Preparation

Prepare resource files for the iOS-side integration Finereport app, including your own iOS project, Finereport-provided resource packs.

Download the integrated resource bundle provided by Finereport and extract it into the folder to see the file as shown:

Where the Frdemo and Frdemo_ directory tree is a sample demo, the description folder is the use of instructions, the remaining three folders is the integration needs to rely on the resource package.

Framework&bundle: It contains the framework and bundle resource files, picture resources (ifimages.xcassets) that the real machine and simulator need to integrate.

WEIXINSDK: the SDK;

Baidumap: The SDK of Baidu map

Frdemo: Integration example, you can set the server address, report path, load the report, that is, directly through the URL to access the report;

Frdemo_ directory tree: Integration Example 2, you can log on to the server, the display directory tree, that is, by sending a user name password for authentication, verify the success of the direct display of Finereport's home page or directory tree.

2. Resource Import

In your own project, import the resource file framework&bundle\ emulator \fineresource.bundle, add framework&bundle\ifimages.xcassets to the project, and in the build Add the Lib package shown in Phases--link Binary with libraries:

Where Finesoft.framework is the resource file provided by Finereport, under the framework&bundle\ real machine \finesoft.framework directory of the extracted folder.

Also, add the SDK and Baidu SDK from the previous download resources in the project, such as:

3. Integrated use of Finereport App

After the resource import configuration is complete, you need to integrate the app, there are two ways to integrate the iOS app, one is directly through the URL Integration Server template, and the other is by sending the username password to the server, after verification through the display Finereport directory tree.

3.1 Direct URL Integration

A direct URL integration report is a direct access to a report on a finereport server through a URL link.

Use Ifentryviewcontroller to load reports in your project, create Ifentryviewcontroller objects based on report path, server path, preview type.

Introduce header file:

1. #import <FineSoft/IFEntryViewController.h>

Generate IFENTRYVIEWCONTROLLER:IFENTRYVIEWCONTROLLER*ENTRYVC = [[Ifentryviewcontroller Al-loc] InitWithPath based on server address and report path: Path Serverurl:url]:

Reportpath: report path, such as APP/DETAILEDDRILLA-PHONE.CPT;

ServerURL: Server address, such as http://192.168.1.100:8075/WebReport/ReportServer;

ViewType: Preview type, optional values are ifentryviewtypepage (Page preview), Ifentryviewtypewrite (fill preview), optional, default to page-break preview;

Parameters: The parameter of report passing, can choose;

If all of the above four interfaces are used, the method is:

-(ID) Initwithpath: (NSString *) Reportpath ServerURL: (NSString *) Serverurlviewtype: (Ifentryviewtype) ViewType Parameters: (nsdictionary *) params;

For example, the URL integration of an online app demo under the form, Direct preview, do not pass parameters, the code is as follows:

1. Ifentryviewcontroller *ENTRYVC = [[Ifentryviewcontroller alloc] initwithpath:@ "app/sales/orders.frm" serverUrl:@ "H Ttp://www.finereporthelp.com:8889/app/reportserver "];

Detailed usage to view Frdemo examples in resource bundles

3.2 Integrated directory tree view template

Integrated directory tree, that is, after sending the user name password to the server authentication, access the system's directory tree, view all the templates under the system.

Use Ifentryviewcontroller to load reports in your project.

Its interface code is as follows:

· Introducing Header Files

1. #import <FineSoft/IFFrameUtils.h>

2. #import <FineSoft/IFFrameDirectoryViewController.h>

· Logon server

1. [Ifframeutils loginto:default_servername serverurl:url withusername:username Andpassword:password success:^{

2.//Login succeeded, load directory tree

3. [Ifframeutils loadreporttree:^ (Nsmutablearray *reportsarray) {

4.//Load success, display directory tree

5. Ifframedirectoryviewcontroller *DIRECTORYVC = [[Ifframedirectoryviewcontroller alloc] Initwithreportsar Ray:reportsarray];

6. [Self.navigationcontroller PRESENTVIEWCONTROLLER:DIRECTORYVC Animated:yes Comple-tion:nil];

7.} failure:^ (NSString *) {

8.}];

9.} failure:^ (NSString *) {

10.}];

Each parameter of the login server means:

ServerName: server name, such as demo server;

ServerURL: Server address, such as http://192.168.1.100:8075/WebReport/ReportServer;

Username: User name;

Password: password;

Success: Login successful callback function (usually loading directory tree);

Failure: Login failed callback function.

Each of its parameters is used as: + (void) Loginto: (NSString *) Servernameserverurl: (NSString *) ServerURL withusername: (NSString *) Usernameandpassword: (NSString *) password success: (void (^) ()) Success failure: (void (^) (NSString *)) failure;

For example, the integration of online app Demo project directory tree, the code is as follows:

1. #import <FineSoft/IFFrameUtils.h>

2. #import <FineSoft/IFFrameDirectoryViewController.h>

3.//Login Server

4. [Ifframeutils loginto:@ "demo server" serv-erurl:@ "Http://www.finereporthelp.com:8889/app/ReportServer" Withuser name:@ "Demo" andpassword:@ "Demo" success:^{

5.//Login succeeded, load directory tree

6. [Ifframeutils loadreporttree:^ (Nsmutablearray *reportsarray) {

7.//Load success, display directory tree

8. Ifframedirectoryviewcontroller *DIRECTORYVC = [[Ifframedirectoryviewcontroller alloc] Initwithreportsar Ray:reportsarray];

9. [Self.navigationcontroller PRESENTVIEWCONTROLLER:DIRECTORYVC Animated:yes Comple-tion:nil];

Ten.} failure:^ (NSString *) {

11.}];

failure:^} (NSString *) {

13.}];

Detailed usage of the frdemo_ tree sample in the resource bundle is available for viewing

4. Precautions

1, need to cooperate with FR8.0 or FR7.1.1 version use;

2, the provided example Frdemo can only run on the real machine, if need to run on the simulator, please replace the framework and bundle files in the framework&bundle/simulator;

3, if you encounter Baidu Map integrated C file conflict error, you can change the other linker flags-all_load to-OBJC.

5. Open Native Report

If the integration is triggered from an HTML element event on WebView, open the native report, then you need to customize WebView inherit UIWebView and rewrite-(BOOL) WebView: (UIWebView *) Webviewtshouldstartloadwithrequest: (Nsurlrequest *) Requestnavigationtype: (Uiwebviewnavigationtype) Navigationtype method to implement. The principle is to parse the URL, and if the URL is a report type, open the report with Entryviewcontroller.

Examples are visible:

1.-(BOOL) WebView: (UIWebView *) WEBVIEWT shouldstartloadwithrequest: (nsurlrequest *) Request Navigationtype: (Uiwebvie Wnavigationtype) 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.//description is normal over-chain

9. Ifwebviewcontroller *towebview = [[Ifwebviewcontroller alloc] initwithurl:[urldict Objectforkey:key_url]];

Towebview.title = @ "link";

[Self Ifpushvc:towebview animated:yes];

.} else {

13.//Description is the report type of the hyperlink

Ifentryviewtype ViewType = ifentryviewtypepage;

if ([[[Urldict Objectforkey:key_op] isequaltostring:key_viewtype_write]) {

ViewType = Ifentryviewtypewrite;

17.}

Ifentryviewcontroller *ENTRYVC = [[Ifentryviewcontroller alloc] initwithpath:[urldict Objectforkey:key_path] Serverurl:[urldict Objectforkey:serverurl_key] Viewtype:viewtype];

Entryvc.title = Urldict[key_path];

[Self IFPUSHVC:ENTRYVC animated:yes];

21.}

. return NO;

23.}

6. Testing

Finereport provides a demo address for testing.

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

User name: demo;

Password: demo;

Available report paths:

App/detaileddrilla-phone.cpt

App/para-phone.cpt

App/detaileddrill-pad.cpt

App/parapad.cpt

App/sales/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

Get ready to integrate the Android project with the Finereport app and download the integrated Resource pack provided by Finereport.

Download the integrated resource bundle provided by Finereport and unzip it to get as many files as shown:

The extracted Libs directory and res directory copies need to be integrated into the Android project, and the jar and Armeabi directories under the Libs directory are referenced in the Android development project as a dependent library, such as:

2. Modify the Androidmanifest.xml file

Open the Androidmanifest.xml file under your own project and write the contents of the extracted Finereport provided androidmanifest.xml to the configuration file under your project

3. Integrate with Finereport App

FineReport Android app offers 2 types of interfaces: directly using URLs to access templates on the server, integrated into your app as a connection, and using directory entry integration, i.e. by verifying your username password, Log in to the home page of Finereportapp or to the table of contents.

3.1 Direct URL Integration

Use URL integration. Directly using the URL to access the server project template, for example, we want to integrate the WORKBOOK2.CPT template under the server, and is the form of filling, then 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=WR Ite ");

3. Intent.setclass (this, integrationactivity.class);

4. StartActivity (Intent);

Note: Op=write indicates that the parameter op is the write fill mode, and the normal preview template does not require the OP parameter to be added.

3.2 Using the catalog Welcome Portal Integration

Use directory Welcome portal integration, directly to the report home page or directory is equivalent to the Finereport app embedded in their app, when need to enter the Finereport app, Just send the appropriate user name password verification to log in to the Finereportapp home page or directory pages, the interface is as follows:

1. Intent welcomeintent = new Intent (this, loadappfromwelcomeactivity.class);

2. Welcomeintent.putextra ("username", "demo"); Data decision System User name

3. Welcomeintent.putextra ("Password", "demo"); Data decision System User password

4. Welcomeintent.putextra ("ServerIP", "Http://www.finereporthelp.com:8889/app/ReportServer"); Data decision System Address IP

5. Welcomeintent.putextra ("ServerName", "Demo server"); Data decision System name

6. StartActivity (welcomeintent);

Note: If the home page is set up on the server system, the login is complete and the page is displayed directly if the home page is not set.

Integrate report mobile into your own mobile app method "IOS, Android"

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.