2017-09-24 3 views
1

NotificationExtenderServiceをOneSignalのドキュメント(ここではOne signal doc)として拡張していますが、trueを返すと通知が表示されなくなることがわかりました。これまでのところ、問題はまだ私のタイスクリプトコード内にhandleNotificationReceivedを引き起こす必要があるということです。NotificationExtenderServiceが起動していませんhandleNotificationReceived

ここでは、Javaコードの下に延びる:私が午前

public class NotificationExtenderBareBonesExample extends NotificationExtenderService { 
@Override 
protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) { 
    receivedResult.payload.lockScreenVisibility = Integer.parseInt("-1"); 
    JSONObject data = receivedResult.payload.additionalData; 
    OverrideSettings overrideSettings = new OverrideSettings(); 
    overrideSettings.extender = new NotificationCompat.Extender() { 
     @Override 
     public NotificationCompat.Builder extend(NotificationCompat.Builder builder) { 
      // Sets the background notification color to Green on Android 5.0+ devices. 
      builder = builder.setVisibility(Integer.parseInt("-1")); 
      builder = builder.setVibrate(new long[]{0L}); 
      return builder.setColor(new BigInteger("800d2f66", 16).intValue()); 
     } 
    }; 
    OSNotificationDisplayedResult displayedResult = displayNotification(overrideSettings); 
    Log.d("OneSignalExample", "Notification displayed with id: " + displayedResult.androidNotificationId); 
    return true; 
} 

}

問題は、(それがadditionalDataを分析し、それに応じた部分を実行します)私は私のNotificationReceivedHandlerがトリガー持つためdisplayNotificationを呼び出す必要があるということです。

イオン2コード:

enter image description here

displayTypeShown値を変更するにはどのような方法があります:それは私のイオンハンドラに到着したら、ここで

this.oneSignal.handleNotificationReceived().subscribe((result) => { 
    alert('received ' + JSON.stringify(result)); 
    thisRef.writeDebug('notification received'); 
    let data = result.payload.additionalData; 
    let chatmessage = ""; 
    if (data != null) { 
     if(typeof data !== 'undefined' && data.length != 0) 
     { 
     if(typeof data.chatmessage !== 'undefined') 
      console.log('chatmessage ok'); 
     if(typeof data.id !== 'undefined') 
      thisRef._callbackOnChatMessage({chatmessage: data.chatmessage, id: data.id.toString()}) 
     if(typeof data.shortgeolocation !== 'undefined') 
     { 
      this._callbackRequestShortLocation(data.shortgeolocation); 
     } 
     } 
     if(typeof data.othertyping !== 'undefined' && typeof thisRef._callbackOnOtherTyping !== 'undefined') 
     { 
     thisRef._callbackOnOtherTyping(data.othertyping); 
     } 
    } 
}); 

は私の通知のプレビューですNotificationExtenderServiceからそれぞれ0とfalseになるようにして、IonicのNotificationReceivedHandlerが呼び出され、警告が表示されないようにします。 (私はこの動作をiOSの下で動作させ、Androidで同じことをするのに苦労している)。解決しよう

は、部分的に、私はcordova.system.library使用して、プラットフォーム/ android.propertiesに3.5.6 にonesignalライブラリをダウングレードする必要がありましたcom.onesignal = [あなたの番号xを維持]:OneSignal:3.5.6 問題を修正します。 は、イオンの場合、ファイルはプラットフォーム/アンドロイド/ project.properties in Android platform

下にあるthisポスト絶対に関連参照してください。

+0

イオンプロジェクトでネイティブJavaクラスをどこに配置しましたか? – thisdotvoid

+0

Androidの部分は、platform-> android-> src-> comの下にあります。そこからプロジェクト名のフォルダとプロジェクトIDのサブフォルダが表示されます。要するに、あなたのMainActivity.javaがどこにあるのかを正確に示します。 AndroidManifest.xmlの中にサービス部分を追加することを忘れないでください。 – Floydus

答えて

0

OneSignalからバージョン3.6.2がこの問題を修正しているというメールが届きました。 Androidのプロパティはcom.onesignal:OneSignal:3.6.2になります。 ファイルを更新するための更新された質問を参照してください。

関連する問題