2016-05-11 54 views

回答

7

您将需要设置一个OneSignal NotificationExtenderService类并将其作为Service添加到您的AndroidManifest.xml

import com.onesignal.OSNotificationPayload; 
import com.onesignal.NotificationExtenderService; 

public class NotificationExtenderBareBonesExample extends NotificationExtenderService { 
    @Override 
    protected boolean onNotificationProcessing(OSNotificationReceivedResult receivedResult) { 
     // Read properties from result. 

     // Returning true tells the OneSignal SDK you have processed the notification and not to display it's own. 
     return true; 
    } 
} 

AndroidManifest.xml

<service 
    android:name=".NotificationExtenderBareBonesExample" 
    android:permission="android.permission.BIND_JOB_SERVICE" 
    android:exported="false"> 
    <intent-filter> 
     <action android:name="com.onesignal.NotificationExtender" /> 
    </intent-filter> 
</service> 

详情请参见该OneSignal的Android Background Data and Notification Overriding文档。

+0

Tnx @jkasten这已经帮了我很多。给了我一个想法,我可以在Onesignal仪表板的键值对中发送我需要的参数。 – Majstor

+0

@Majstor您可以请提供代码我们如何隐藏onesignal通知 –

+0

@KarandeepAtwal我更新了我对3.0 SDK中可用内容的回答。 – jkasten