uniapp的插件扩展中需要集成一个第三方SDK 需要传入context,但是传入mWXSDKInstance.getContext()之后并没有任何效果
下面是原生写法 是没有问题的
然后是混合开发的插件 不能初始化
要怎么获取这个有效的context
@JSMethod(uiThread=true)
public void initNotificationCallback(JSCallback callback) {
Context context = this.mWXSDKInstance.getContext();
PLInitializer.shared()
.setLog(new ILog()
{
public void info(String message)
{
Log.i("监听", message);
}
}).setNotificationReceivedListener(new OnNotificationReceivedListener(callback)
{
public void onPaymentTypeReceived(Map<String, String> params)
{
Log.i("监听", params.toString());
WeexPluginMonitorModule.this.mWXSDKInstance.fireGlobalEventCallback("onPaymentTypeReceived", WeexPluginMonitorModule.this.mapParam(params));
if (this.val$callback != null)
this.val$callback.invokeAndKeepAlive(params);
}
public void onUndefineNotificationReceived(String pkg, String content)
{
}
});
}
@JSMethod(uiThread=true)
public void initNotificationCallback(JSCallback callback) {
Context context = this.mWXSDKInstance.getContext();
PLInitializer.shared()
.setLog(new ILog()
{
public void info(String message)
{
Log.i("监听", message);
}
}).setNotificationReceivedListener(new OnNotificationReceivedListener(callback)
{
public void onPaymentTypeReceived(Map<String, String> params)
{
Log.i("监听", params.toString());
WeexPluginMonitorModule.this.mWXSDKInstance.fireGlobalEventCallback("onPaymentTypeReceived", WeexPluginMonitorModule.this.mapParam(params));
if (this.val$callback != null)
this.val$callback.invokeAndKeepAlive(params);
}
public void onUndefineNotificationReceived(String pkg, String content)
{
}
});
}