Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
836 stars 451 forks source link

Push notification shown at top of android but no alert is coming #141

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi, I am trying something on NativeScript for push notification on android and am getting push notification at the top of android phone(notification area), but when I click on the notification my app opens but the alert written in code is not shown,also error is thrown in console.

There are 2 parts to it. 1) This error needs to be solved. 2) I need to handle click event of notification in my application , like show a dialog, asking OK/Cancel.

I have got this code from github only(https://github.com/NativeScript/push-plugin). Can someone please find error I am doing .Code is as follows `var pushPlugin = require("nativescript-push-notifications"); var settings = { // Android settings senderID: '539XXXXXXX38', // Android: Required setting with the sender/project number notificationCallbackAndroid: function(message) { // Android: Callback to invoke when a new push is received. alert("JSON.stringify(message)");
},

    // iOS settings
    badge: true, // Enable setting badge through Push Notification
    sound: true, // Enable playing a sound
    alert: true, // Enable creating a alert

    // Callback to invoke, when a push is received on iOS
    notificationCallbackIOS: function(message) {
        alert(JSON.stringify(message));
    }
};

pushPlugin.register(settings,
    // Success callback
    function(token) {
           // if we're on android device we have the onMessageReceived function to subscribe
        // for push notifications
        if(pushPlugin.onMessageReceived) {
            pushPlugin.onMessageReceived(settings.notificationCallbackAndroid);
        }

        alert('Device registered successfully');
    },
    // Error Callback
    function(error){
        alert(error.message);
    }
);`

Error getting on console: I/dalvikvm(14721): Could not find method org.json.JSONObject.wrap, referenced fr om method com.telerik.pushplugin.PushPlugin.executeOnMessageReceivedCallback W/dalvikvm(14721): VFY: unable to resolve static method 55897: Lorg/json/JSONObj ect;.wrap (Ljava/lang/Object;)Ljava/lang/Object;

ghost commented 8 years ago

Also AndroidManifest.xml seems correct: file location : platforms\android\build\intermediates\manifests\full\push-plugin\debug

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

And

    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="com.pushApp.gcm" />
        </intent-filter>
    </receiver>

    <service
        android:name="com.telerik.pushplugin.PushPlugin"
        android:exported="false" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>

AndroidManifest .txt

heypiotr commented 8 years ago

We're probably not the best people to ask about errors in somebody else's code. You'll get better and more targeted help if you open an issue with the authors of the code/plugin you're using. Thanks for your understanding!