[英]xtify + phonegap enable sound and vibration
我正在使用Phonegap和Xtify在應用程序中構建消息推送功能。 我收到消息,但沒有聲音和振動。 如何啟用它們?
XtifyCordovaPlugin.js中沒有任何功能。 SDK中只有一個名為“ NotificationsPreference.setSoundEnabled(context,true);”的函數。 它需要上下文。 上下文是什么?
我的活動
package com.example.test;
import android.app.Activity;
import android.app.Notification;
import android.content.Context;
import android.os.Bundle;
import org.apache.cordova.*;
import com.xtify.cordova.XtifyCordovaPlugin;
import com.xtify.sdk.NotificationsUtility;
import com.xtify.sdk.api.NotificationsPreference;
public class MainActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
XtifyCordovaPlugin.processActivityExtras(getIntent().getExtras(), this);
//The Line
NotificationsPreference.setSoundEnabled(context, true);
}
}
在此先感謝您的幫助!
在這種情況下,您可以使用:
NotificationsPreference.setSoundEnabled(this, true);
MainActivity擴展了DroidGap,后者擴展了Activity,后者又擴展了Context。 因此,實際上DroidGap是一個上下文。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.