Open Platform for ios application access
I tried to access the public platform on the server a few days ago, and yesterday I checked the application access to the open platform.
Differences between open platforms and public platforms
The public platform targets public accounts. In addition to providing the management backend, it also opens a number of interfaces to connect servers and developers' own application systems.
The Open Platform is an integrated access method, not limited to public accounts (subscription numbers, service numbers). Mobile apps and web applications can also be connected through the open platform. It can be said that the API part of the public platform is a subset of the open platform.
The open platform consists of three parts: mobile apps, WEB applications, and public accounts.
Functions of mobile APP access to open platforms
Currently, after a mobile APP is connected to the open platform, you can obtain the following features:
1. send messages to friends
2. send messages to the circle of friends
3. add content to "my favorites"
4. log on to the APP with an account to obtain the account information.
5. Payment supported
In the circle of friends, you can see a Message followed by "from XXX", which is the capability obtained after the XXX application is connected to the open platform.
Ios app access method
The process and Code are not complex. For details, refer to the open platform official website. This article will not go into detail. Note that you need to configure the URL Type of your APP in xcode. The URL Schemas needs to enter the app id provided by the open platform. If this step is missing, you can send a message, but after the message is sent, you cannot jump back to your APP, because the client also uses the openURL method to jump back to your APP, you need your APP to register the URL Schemas
Connection principle
First, a major restriction is that the APP cannot directly send messages to the server through the provided SDK. Instead, open the application from the developer's APP, send the message, and then jump back to the developer's APP. That is to say, the interaction between the APP and the APP is completed through the jump between applications, so the core is the two methods of iOS:
- (BOOL)openURL:(NSURL*)url;
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
The message sending code is:
[WXApi sendReq:req];
Of course, the SDK is not open-source, so we can't see anything from this line of code. However, it is easy to think that the way to jump to another app is the openURL method in iOS, so this line of code is similar:
NSString *weixinURL = @"weixin_schema://app_id?title=xxx&content=xxx";[[UIApplication sharedApplication] openURL:[NSURL URLWithString:weixinURL]];
Through weixin_schema, the application installed on the machine is opened; related parameters are added at the end of the URL, and post-resolution is performed. After the message is sent in, openURL is also called, and the APP is returned to the developer:
The URL is wx_xxxxxxxxxxx: // platformId = wechat
This URL is intercepted by this method in AppDelegate:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ return [WXApi handleOpenURL:url delegate:self];}
Then the handleOpenURL method is called:
-(Void) onResp :( BaseResp *) resp {NSString * strTitle = [NSString stringWithFormat: @ "Send message result"]; NSString * strMsg = [NSString stringWithFormat: @ "errcode: % d ", resp. errCode]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: strTitle message: strMsg delegate: nil cancelButtonTitle: @ "OK" failed: nil]; [alert show];}
This is how the interaction works. Specifically, there are two processes in the Code:
1. The application sends messages to IOT platform. The application calls the sendReq method and then processes the response in the onResp method.
2. Send a message to the application. The application processes the request in onReq, and then calls the sendResp method to send a response
The parameters used in these two processes are all encapsulation classes provided by the SDK, such as SendMessageToWXReq and WXMediaMessage.
Connection restrictions
As mentioned above, because the SDK does not provide the application's ability to send requests directly to the server, but can only jump to the APP with parameters, the access restrictions are relatively large and many things cannot be done.
For example, a user's device must be installed and is already logged on. Therefore, it is difficult to connect many apps for iPad. Because there are very few users installed on the iPad, they are generally installed on mobile phones.
In addition, you cannot select users to send messages in your APP. You can only edit the content, jump to the page, and select the friends you want to send in the address book.
You cannot directly send a friend request to your account based on your mobile phone number.
......
Even so, after the connection, it still has a great value for the social communication of the APP, so now we can see that most apps have access functions.