Cocos2d-x local notification

Cocos2d-x local notification
0

#1

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!


#2

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);
}

#3

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.


#4

Hi

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


#5

hzlov’s suggestion seems to work on paper


#6

@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.


#7

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


#8

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?


#9

Hopefully in the next day or 2, we understand it’s really important to you so keep pestering us at support@sonarsystems.co.uk


#10

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


#11

:smiley: Your welcome


#12

is there any update for android notification…?


#13

Nothing ATM sorry


#14

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


#15

@Elrinth

Hi,

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