Project description
- 1. Status: HTML5 developers do not understand OC,OC developers do not understand HTML5, both sides of the phonegap are not too deep research, did not adopt phonegap push plugin
- 2. Issue: After PhoneGap-based iOS receives a push message, to jump to the messagecenter.html file in the www/html directory
Practical Solutions
Configure the push certificate, the process of integrated Aurora push is skipped over the table.
First try to load the messagecenter.html directly in the Didreceiveremotenotification method after accepting the remote push message, the code is as follows:
NSString*filePath=[[NSBundle mainBundle ]pathForResource:@"message" ofType:@"html" inDirectory:@"www/html/mydiving/"];[self.viewController.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:filePath]]];
During the test, it was found that PhoneGap loading the portal HTML can only be configured in CONFIG. If you use the above method to manually load messagecenter.html, if the application is in a non-bootable state, it will invalidate the jump to other HTML pages. If the application is running in the background, it can jump normally.
In conclusion, the following logic is taken by judging the current running state of the application:
- 1. When the program is in the Uiapplicationstatebackground state, use the above scenario to load
- 2. When the program is in the Uiapplicationstateactive state, a popup Uialertview is prompted
- 3. When the program is uiapplicationstateinactive state, the default entry configured by the PhoneGap is entered, not processed
Optimization scenario (not verified)
When the application receives a remote push, the information is passed to index.html (the default HTML entry for PhoneGap) in the Didreceiveremotenotification method, and the jump logic is handled by the HTML side, and the method of the argument is described in PhoneGap OC gives the value of JS method.
Front-end HTML engineer working overtime has been crazy, dare not Disturb, Amitabha
phonegap|ios| push