Cocos2d-x local notification

Cocos2d-x local notification



I am trying this:

and I am getting:
Failed to find static method id of showLocalNotification

or it would simply crash (java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.Context’ on a null object reference), if I named the #define CLASS_NAME “org/cocos2dx/cpp/Cocos2dxActivity” differently.

Has anyone gotten this to work, if so. Please enlighten me what I must do!


I think there should be some codes for JavaVM.
Try to add this code at

void cocos_android_app_init (JNIEnv* env, jobject thiz) {
    AppDelegate *pAppDelegate = new AppDelegate();
    JavaVM* vm;


I can now confirm I have this working. Atleast on android :smile:

Here’s what is needed to do on latest cocos2d-x:
You’ll have an in the\src\org\cocos2dx\cpp folder, edit that one so it looks like this:

I’ll give this a whirl in xcode now for iOS devices.



Is it possible to setup notification on exit app to show lets say after an hour?


hzlov’s suggestion seems to work on paper


@Elrinth Did you got local notification working in ios. Can you share the code?

I am looking for local notification system that works on both android and ios.


You can use this for iOS, our Cocos Helper which will soon have Android support as well.

Official Webpage:


i love cocos helper and i am already using it. Also embedded local notification for ios, but i want to launch the app within a week, so looking for other solutions for local notification on android.

When are you planning to launch it for android, and is there some temporary solution for android till then?


Hopefully in the next day or 2, we understand it’s really important to you so keep pestering us at


Hehehehe, i can do that… :grinning: Thank you…


:smiley: Your welcome


is there any update for android notification…?


Nothing ATM sorry


i am using the above code, it’s working on both iOS and android.




I am able to run the code successfully but i am not getting local notification. What should i do in this case.