I'm developing on ionic but I get a problem when I'm checking if there's internet connection.
This is my code for checking if internet connection:
$scope.checkConnection = function() {
if(navigator && navigator.connection && navigator.connection.type === 'none') {alert('no conexion');}
else{alert('conectado');}
};
I call it in index.html like this:
<body ng-app="myApp" ng-controller="checkNetworkController" ng-init="checkConnection()">
When I start the app I get:
Application Error - The connection to the server was unsuccessful. (file:///android_asset/www/index.html)
If I don't call checkConnection everything works fine.
I've tried to reinstall the cordova network plugin and I have added in config.xml:
<preference name="loadUrlTimeoutValue" value="700000" />
But nothing works. Any idea?
Use Cordova plugin add cordova-plugin-network-information Then window.Connection for Checking available internet.
if(window.Connection){
if(navigator.connection.type == Connection.NONE) {
$state.go("error");
alert("offline")
}else{
console.log(navigator.connection.type);
alert("online")
}
}
Finally I got the solution.
I use the same code
if(navigator && navigator.connection && navigator.connection.type === 'none')
{alert('no conexion');}
else{alert('conectado');}
But instead on a function, I include it in the $ionicPlatform.ready(function() at the app.js and now it works.
Related
We are facing a strange situation where we have an old legacy Meteor server that we are no longer able to deploy any new codes.
We are moving away from the old server to a new server.
We wanted to keep the old server running as a "reference", but there are cronjobs that still regularly send out emails to clients in the database.
We have to stop these emails from being sent out, without restarting the server or redeploying the codes if possible. Is there any way to do it?
p/s: This is how the server is sending out emails using the Email Meteor package:
Meteor.methods({
sendEmail: function(options) {
// compile the template
var template = _.template(Assets.getText(options.template));
if (Meteor.DEBUG) {
Email.send({
to: Meteor.EMAIL_ADMIN,
from: options.from || Meteor.REPLYTO,
subject: options.subject || '',
html: template(options.data)
});
} else {
Email.send({
to: options.to,
from: options.from || Meteor.REPLYTO,
subject: options.subject || '',
html: template(options.data)
});
}
},
After upgrading to com.crashlytics.sdk.android:crashlytics:2.7.1#aar (from 2.6.8), I can't disable Crashlytics anymore in my Firebase app.
Looks like there's some code in Crashlytics library itself that initializes Fabric with Crashlytics kit enabled whenever it detects that it's running inside a Firebase application. Indeed initializing with Crashlytics enabled and with ext.enableCrashlytics = false throws an UnmetDependencyException and crashes the app at startup (in fact, before my code in Application.onCreate runs).
Does anyone know a workaround for that? Sticking with 2.6.8 works for now.
This is what I have in my code that used to work until an upgrade:
app/build.gradle:
ext.enableCrashlytics = false
Application.java (onCreate, full method body as requested):
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
return;
}
LeakCanary.install(this);
// First Fabric invocation
Fabric.with(this, new Crashlytics.Builder().core(
new CrashlyticsCore.Builder().disabled(true).build()).build());
RxJavaPlugins.setErrorHandler(e -> LOGGER.error("Undeliverable RxJava error", e));
// First Firebase invocation
FirebaseDatabase db = FirebaseDatabase.getInstance();
if (BuildConfig.DEBUG) {
db.setLogLevel(com.google.firebase.database.Logger.Level.DEBUG);
}
db.setPersistenceEnabled(true);
according to mike answer, im add my code:
Gradle:
buildTypes {
release {
manifestPlaceholders = [crashlyticsEnabled: true]
}
debug {
manifestPlaceholders = [crashlyticsEnabled: false]
}
}
Manifest.xml:
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlyticsEnabled}" />
Mike from Fabric here. Use:
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
if you want to disable Crashlytics while using Firebase.
Along with mikes above answer,
If you are setting firebase crash properties somewhere in your code, make sure that you don't set them for debug code, otherwise you might notice strange behaviour for the app.
if (!BuildConfig.DEBUG) {
Crashlytics.setUserIdentifier(DataStore.storeId)
}
I'm having problems with adding an audio or a video service to a coversation.
The chat service works fine for me.
When I add a video or an audio service I get following error:
Error: GET /ucwa/oauth/v1/applications/113925534802/communication/mediaRelayAccessToken failed: 404
{
[functions]: ,
__proto__: { },
code: "RequestFailed",
description: "GET /ucwa/oauth/v1/applications/113925534802/communication/mediaRelayAccessToken failed: 404",
message: "GET /ucwa/oauth/v1/applications/113925534802/communication/mediaRelayAccessToken failed: 404",
name: "Error",
req: { },
rsp: { },
stack: "Error: GET /ucwa/oauth/v1/applications/113925534802/communication/mediaRelayAccessToken failed: 404
at process (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:8079:29)
at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:8018:29)
at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:1714:25)
at map (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:1331:25)
at decompose (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:8017:25)
at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:8007:29)
at handle (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:2220:33)
at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:698:25)"
}
The Skype For Business Plugin is installed and works fine.
A Skype Edge server is currently not installed.
I'm using Internet Explorer 11.
The error occurs with the Skype Web SDK On Prem Sample from Microsoft as well as on my own website.
When I try to add video or audio for the second time to the same conversation i dont get any error message at all, but it still doesn't work. The request doesnt show up in the dev tools nor in fiddler. I'm using the latest version of the Skype SDk bootstrapper.
Both clients and server are in the same subnet.
Thanks in advance.
I encountered the same problem. Not sure how it happens, but the sdk has troubles to fetch or apply the media config.
You can use the this workaround:
Following line 18,892 in the debug version of the sdk, comment out both calls:
uninit();
throw error;
in the function init() of the section MediaConfig. Resulting in:
function init() {
pcMediaConfig = mediaPlugin.createComponent({
type: 'MediaPlatformConfig',
hide: true,
inproc: false
});
pcMediaConfig.event(onPluginComponentEvent);
pcMediaConfig.state.changed(function (state) {
log('pcMediaConfig.state = ' + state);
});
var p = pcMediaConfig.load().then(getMediaConfig).then(setMediaConfig).then(null, function (error) {
log('MediaConfig::init rejected');
//uninit();
//throw error;
});
return p;
}
Therefore you have to download the bootstrapper and the sdk to permanently apply the patch. To do this just fetch both in the debug version (bootstrapper version 1.2.5) and replace in function onConfig(config) line 48
}, config.corsScript && (scriptAttributes.crossOrigin = ""), loader.loadScript(getPackageUrl(config), null, handleError, scriptAttributes);
with
}, config.corsScript && (scriptAttributes.crossOrigin = ""), loader.loadScript("./scripts/SkypeSDK.js", null, handleError, scriptAttributes);
or your equivalent path
This is currently a limitation of the Skype Web SDK: it has a dependency on the mediaRelayAccessToken to proceed with audio/video calls. The dev team is aware of this issue and it may be fixed in a future release of Skype Web SDK.
The hacky way recommended above is basically to allow the SDK to continue the call upon missing mediaRelayAccessToken, so it may let you bypass the issue.
The media relay access token is returned by an edge server, so you may also try to deploy an edge server to work around this issue.
I'm trying to use Meteor and this Cordova plugin -https://github.com/don/cordova-plugin-ble-central - added to my project using meteor add cordova in order to connect to a Bluetooth LE device (TI Sensortag). All I want to do to begin with is, when a link is clicked, to connect to the device and show a message.
I have the following code in the events section of my template javascript.
Template.measure.events({'click [data-action=scan-connect-stream]':
function(event, template) {
event.preventDefault();
if (Meteor.isCordova) {
Meteor.startup(function () {
ble.connect('24:09:00:DE:00:42',
function(){
alert('Connect success');
return;
},
function(){
alert('Connect failed');
return;
});
});
}
}
});
My problem is that sometimes the code works and I get a 'Connect success' alert but more often than not it it fails to connect and shows the 'Connect failed' alert. Before I added the return statements in the success and fail callbacks it didn't work at all.
I'm debugging this on an android device (meteor run android-device --verbose) and can see via adb logcat that the BLE Connect event in the Cordova plugin is firing but then doesn't connect. I get the same issue debugging on two different phones and when using a BLE device that isn't a TI Sensortag so I'm guessing this is an problem with the way the plugin is interacting with Meteor (maybe Meteor isn't waiting long enough for a success callback?).
Has anyone used this plugin successfully with Meteor or can anyone provide any clue as to what I'm doing wrong? Should I try wrapping it in a Meteor package or is there any way I can give the plugin more time to respond before the success or fail callbacks fire? Any help would be much appreciated!
For anyone who's having similar issues this is what sorted it for me. I put the ble.connect call into the success callback of the ble.scan function. Not sure why but scanning for a few seconds first does the job.
Template.measure.events({
'click [data-action=scan-connect-stream]': function(event, template) {
event.preventDefault();
if (Meteor.isCordova) {
Meteor.startup(function () {
device_id = '24:09:00:DE:00:42';
ble.scan([], 5,
function(peripherals){
connectDevice(device_id);
},
function(){
alert('No devices found');
}
);
});
}
}
});
var connectDevice = function (device_id) {
ble.connect(device_id,
function(){
alert('Device ' + device_id + ' connnected');
},
function(){
alert('Couldn\'t connect to device ' + device_id);
});
}
If anyone can explain why the ble.connect won't work on its own that'd be great!
EDIT: Looking at the Android code it seems that the plugin is designed in such a way that ble.scan has to be called before calling ble.connect. The ble.scan causes a LinkedHashMap in the Android code to be populated with any discovered devices. Only once the device is listed in the LinkedHashMap can you then connect to it using ble.connect.
My application is not spiderable both on local and production.
When I go to http://localhost:3000/?_escaped_fragment_=, I can see the following error appears (phantom is killed after 15 seconds):
spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }
It seems that many other people got this problem:
https://github.com/gadicc/meteor-phantomjs/issues/1
https://groups.google.com/forum/#!msg/meteor-talk/Lnm9HFs4MgM/YKDMR80fVecJ
https://groups.google.com/forum/#!topic/meteor-talk/7ZbidddRGo4
The thing is I am not using observatory or select2 and all my publications return a cursor. According to me, the problem comes from the minification. I just read in this thread that someone succeed to display "SyntaxError: Parse error". How can I know more about what is going wrong with Phantom and which file is causing the problem?
This happens when spiderable is waiting for subscriptions that fail to return any data and end up timing out, as mentioned in some of the threads you linked.
Make sure that all of your publish functions are either returning a cursor, a (possibly empty) list of cursors, or sending this.ready().
Meteor APM may be useful in determining which publications aren't returning.
If you want to know more about what is wrong with phatomjs, you might try this code (1):
// Put your URL below, no "?_escaped_fragment_=" necessary
var url = "http://your-url.com/";
var page = require('webpage').create();
page.open(url);
setInterval(function() {
var ready = page.evaluate(function () {
if (typeof Meteor !== 'undefined'
&& typeof(Meteor.status) !== 'undefined'
&& Meteor.status().connected) {
Deps.flush();
return DDP._allSubscriptionsReady();
}
return false;
});
if (ready) {
var out = page.content;
out = out.replace(/<script[^>]+>(.|\n|\r)*?<\/script\s*>/ig, '');
out = out.replace('<meta name=\"fragment\" content=\"!\">', '');
console.log(out);
phantom.exit();
}
}, 100);
For use in local, install phantomjs. Then outside your app, create a file phantomtest.js with the code above. And run phantomjs phantomtest.js
Another thing that maybe you can try is to use UglifyJS to catch some errors in the minified JS file as Payner35 did.
My problem was coming from SSL. You can have a complete overview of what I did here.
Edit the spiderable source and add --ignore-ssl-errors=yes to the phantomjs command line, it will work.