The quick cocos2dx game engine lua calls the oc code to implement local push, cocos2dxlua

Source: Internet
Author: User

The quick cocos2dx game engine lua calls the oc code to implement local push, cocos2dxlua

In my blog titled "how to implement local push for ios, compatible with ios8.
Now we will introduce how to call the oc method interface we have previously written in lua to implement the push function at the lua layer, mainly based on the engine of quick cocos2dx V3.3.
The luaoc. callStaticMethod (className, methodName, args) interface is implemented in the luaoc. lua file in quick. It can be seen that only static methods in oc can be called. Therefore, I add the following method to the icationicationhelper. m file:

1 + (void) sendNotificationByLua :( NSDictionary *) dic 2 {3 NSString * firedate = [dic objectForKey: @ "firedate"]; // obtain the related parameter 4 NSString * key = [dic objectForKey: @ "key"]; 5 NSString * message = [dic objectForKey: @ "message"]; 6 icationicationhelper * instance = [NotificationHelper shareInstance]; 7 [instance addNotifiction: firedate keyA: key messageA: message]; 8} 9 + (void) removeNotificationByLua :( NSDictionary *) dic10 {11 NSString * key = [dic objectForKey: @ "key"]; 12 [NotificationHelper shareInstance] removeLocalNotificationByKey: key]; 13}

The function of sending and deleting notifications is mainly implemented. Other requirements can be handled based on actual projects.
In the lua project, you can use the following statement to call the Methods stated above:

1 local params = {2 firedate = "18:20:00", 3 key = "fixedNoti", 4 message = "Fixed Point notification from lua" 6} 7 luaoc. callStaticMethod ("icationicationhelper", "sendNotificationByLua", params) 8 end

Introduction complete! Now we only implement local push of oc. If we need remote push, we hope some enthusiastic netizens can give us some suggestions and ideas. As far as I know, android can be pushed remotely through JPush.
If you want to launch a game project, such as ranking changes, users being attacked, and so on, you need to push the game to users to increase the exposure of our game. If you have done this kind of function, I hope to provide a solution. Thank you!

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.