Cocos2d-x local notification

Hi!

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 android.app.Activity.getApplicationContext()’ 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 proj.android/jni/hellocpp/main.cpp

void cocos_android_app_init (JNIEnv* env, jobject thiz) {
    LOGD("cocos_android_app_init");
    AppDelegate *pAppDelegate = new AppDelegate();
    
    JavaVM* vm;
    env->GetJavaVM(&vm);
    PluginJniHelper::setJavaVM(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 AppActivity.java in the proj.android\src\org\cocos2dx\cpp folder, edit that one so it looks like this:
http://pastebin.com/fXHTdXhZ

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

Hi

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.

GitHub: https://github.com/SonarSystems/Cocos-Helper
Official Webpage: http://sonarsystems.co.uk/cocoshelper.php

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 support@sonarsystems.co.uk

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.

@Elrinth

Hi,

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