I'm writing some Mono For Android code to use Urban Airship Push
Notifications (www.http://urbanairship.com). I have downloaded the Urban
Airship sample java android project and can get everything working using
their Java project but need to create a Mono For Android project and make
some calls to their JAR file (urbanairship-lib-1.0.7.jar) which I have
included in my project and seem to be able to access the Java classes and
methods using JNIENV, although this is the first time I have used JNIENV and
feeling my way and not 100% I'm doing the right thing. I need to make the
Java calls listed below in C# using JNIENV which I've also started to do as
a test below but am getting an error when calling
JNIEnv.CallStaticVoidMethod, saying invalid application configuration which
reading up was suggesting that the airshipconfig.properties might not be
right but the file is the same as my Java Android project and works fine in
there.
I've included airshipconfig.properties in my assets folder and is identical
settings to the Java project that I have working. I think it maybe where I'm
trying to return the AirshipConfigOptions from loaddefaultOptions method as
I'm not sure what call to make to return a AirshipConfigOptions type with
JNIENV
I was wondering if anyone else had used Urban Airship from Mono For Android
(I have Urban Airship working in MonoTouch fine and also have used C2DM
directly without Urban Airship and that works fine too) and think I could do
with help me with the JNIENV calls. I can provide more detail if anything is
missing here.
Thanks
-> Java Android Code
public class MyApplication extends Application {
@Override
public void onCreate() {
AirshipConfigOptions options =
AirshipConfigOptions.loadDefaultOptions(this);
UAirship.takeOff(this, options);
}
public static com.urbanairship.AirshipConfigOptions
loadDefaultOptions(android.content.Context context) { /* compiled code */ }
public static void takeOff(android.app.Application application,
com.urbanairship.AirshipConfigOptions airshipConfigOptions) { /* compiled
code */ }
-> C# Mono For Android Code
private void Temp1()
{
IntPtr ip_airshipConfigOptions =
JNIEnv.FindClass("com/urbanairship/AirshipConfigOptions");
if (ip_airshipConfigOptions == IntPtr.Zero)
{
throw new InvalidOperationException("Counldn't find java class !");
}
IntPtr methodId = JNIEnv.GetStaticMethodID(ip_airshipConfigOptions,
"loadDefaultOptions",
"(Landroid/content/Context;)Lcom/urbanairship/AirshipConfigOptions;");
if (methodId == IntPtr.Zero)
{
throw new InvalidOperationException("Couldn't find java class !");
}
var methodPtr = JNIEnv.CallStaticObjectMethod(ip_airshipConfigOptions,
methodId, new JValue(this.Application));
IntPtr ip_uairship = JNIEnv.FindClass("com/urbanairship/UAirship");
if (ip_uairship == IntPtr.Zero)
{
throw new InvalidOperationException("Couldn't find java class !");
}
// Test different options ???
IntPtr methodId2 = JNIEnv.GetStaticMethodID(ip_uairship, "takeOff",
"(Landroid/app/Application;Lcom/urbanairship/AirshipConfigOptions;)V");
// Test different options ???
IntPtr methodId3 = JNIEnv.GetStaticMethodID(ip_uairship, "takeOff",
"(Landroid/app/Application;)V");
// Call UAirship.takeOff(this, options). Not sure if these parameters
are specified correctly
JNIEnv.CallStaticVoidMethod(ip_uairship, methodId2, new
JValue(this.Application), new JValue(methodPtr));
}
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Urban-Airship-Push-Notifications-JNIENV-tp5553668p5553668.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid