繁体   English   中英

xtify + phonegap启用声音和振动

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM