I'm getting started with PhoneGap on iOS and not having much luck. My app is stuck on the splash screen and nothing is shown in Phoegap Build's console.
The screenshot at http://i.imgur.com/Ru9n3ET.png shows both my file structure and skeleton code. The only thing I see from the app is the alert of '1' called from body's onload event. Nothing else is shown. Is there a glaring mistake which is killing the app?
alert(1) is coming from javaScript and you has nothing to do with phonegap.
You would want to make sure that your code directory has the necessary API's that call Phonegap code. It would look like something below:
package com.news.newsfinder;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
You must have cordova.jar in your build path and cordova.js in your js directory.
Then your javascript code to call phonegap API's can become something like this.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
//code to check what type of internet connection a device is using, wifi, 2G, 3G...
}
The above code which has a package com.news.newsfinder will make an APP in play store like below:
http://play.google.com/store/apps/details?id=com.news.newsfinder
Related
I'm currently experiencing this issue https://github.com/rnmapbox/maps/issues/2514
wherein inside my code mapbox component, if compassViewPosition is added, it terminates the app without even throwing an error. anyone else encountered something related to this (read, passed through or dreamt about); feel free to comment out. Happy to get enlightened here.
import React from 'react';
import MapboxGL from '#rnmapbox/maps';
class BugReportExample extends React.Component {
render() {
return (
<MapboxGL.MapView
compassViewPosition={3} // adding this line terminates the app (not tested in android yet, and no error from try catch)
/>
);
}
}
I'm in "react-native": "~0.66.5" and I'm using "#rnmapbox/maps": "rnmapbox/maps#main",
Previous package I'm using was "#react-native-mapbox-gl/maps": "^8.5.0" and it works fine here. I'm trying to upgrade to the newer package (I know it's not on stable release yet but wanna know if I'm the only one experiencing this).
I have some experience with React but I'm new to React Native.
I've played around for a while, but I got stuck when I tried to write a basic native module for iOS. I've tried with both Swift and Objective C. (I have some basic experience with Swift, but Objective C is completely new for me)
Some context:
The project is created with react-native-cli 2.0.1
I use XCode 9.1
Here is the .swift class
import Foundation
#objc(Something)
class Something: NSObject {
#objc
func printSomething() -> Void {
print("Something")
}
}
Here is the bridge file
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#interface RCT_EXTERN_MODULE(Something, NSObject)
RCT_EXTERN_METHOD(printSomething)
#end
And the Project-Brigding-Header.h
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import <React/RCTBridgeModule.h>
My App.js file
...
import { NativeModules } from 'react-native';
...
type Props = {};
export default class App extends Component<Props> {
componentDidMount() {
console.log('NativeModules: ', NativeModules);
}
...
}
Here is the problem. The output of console.log() says NativeModules is an empty object:
2018-02-22 18:19:04.590 [info][tid:com.facebook.react.JavaScript] 'NativeModules', {}
2018-02-22 18:19:04.589970+0200 velimo_app_rn[14748:400982] 'NativeModules', {}
I don't understand what I'm doing wrong. I've read pretty much everything I could find only related to the topic but I can't see what I do wrong.
If you have any suggestion, please let me know. Thanks!
The solution was to log the module name console.log(NativeModules.Something), not the whole NativeModules object. It wasn't anything wrong with my setup.
If you made changes to the native iOS code, then you need to rebuild the project by
rerunning npx react-native run-ios and restart the server npx react-native start.
I also relaunched the app in the simulator.
Here incase of android firebase crash can be implemented in APPLICATION class like.. below example
(...here, if android app is crashed this overrriden method uncaughtException(Thread thread, Throwable e) is called where we report crash to firebase...)
So, I want to know if there is any better way to implement firebase crash in iOS swift 3 like this.
/** onCreate method of MainApplication.java */
#Override
public void onCreate() {
super.onCreate();
reportFirebaseCrash();
}
/** Report FirebaseCrash Exception if application crashed */
private void reportFirebaseCrash() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
#Override
public void uncaughtException(Thread thread, Throwable e) {
AppUtils.showLog(TAG, "reportFirebaseCrash");
FirebaseCrash.report(e);
}
});
}
Highly recommend you check out the Firebase docs — they're quite well done and should give you all the help you need to get started.
In particular, the simplest way to get up and running is to use the crash reporting pod:
pod 'Firebase/Crash'
Then you need to configure a FIRApp shared instance. Once that's set up (or if you have already), you need to configure your build system to upload crash reports. The docs link includes all the necessary details to do it, but tl;dr, you need to create a new Run Script build phase:
# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id
# Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
"${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"
Firebase also supports Bitcode in order to gather crash data from production users.
I've made a tester class to test the vibration on an iPod Touch but the vibration doesn't work when tested on the device. I've imported all relevant extensions and linked to the relevant Adobe AIR library classes as per this question and answer. Am I using a wrong callback or something?
package
{
import flash.display.Sprite;
import com.adobe.nativeExtensions.Vibration;
public class Test extends Sprite
{
public function Test()
{
run();
}
public function run(): void {
var vibe:Vibration;
if (Vibration.isSupported)
{
vibe = new Vibration();
vibe.vibrate(25000);
}
}
}
}
EDIT: Found out that iPod Touches don't have vibration sensor. After testing this on an iPhone 5, it still doesn't work. As soon as the app is launched, it crashes (and closes) without vibrating.
iPod Touch do not support vibration. :)
I am new to Blackberry development and Im trying to simple get a BrowserField working.
I get this errormessage:
Tried reinstalling JDE etc. etc. but the app always gets an error when I run it on the simulator..
Any ideas?
Here is my code:
package mypackage;
import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;
/**
* This class extends the UiApplication class, providing a graphical user interface.
*/
public class HelloBlackBerry extends UiApplication {
private MainScreen _screen;
private BrowserField _bf2;
HelloBlackBerry()
{
_bf2 = new BrowserField();
_screen = new MainScreen();
_screen.add(_bf2);
pushScreen(_screen);
_bf2.requestContent("http://www.blackberry.com");
}
public static void main(String[] args)
{
HelloBlackBerry app = new HelloBlackBerry();
app.enterEventDispatcher();
}
}
I do not have a Blackberry device to test on yet.
Normally, enabling the Mobile Data System Connection Service (aka MDS-CS) would have solved this BUT the MDS-CS version supplied with JRE 7.0.0 (9930 simulator) is incorrect! The original post on BlackBerry's forums can be found here.
According to this post:
An incorrect version of MDS-CS simulator was included in 7.0. To correct it you can delete it and copy the version from 6.0.
Deleting the invalid MDS version from JRE 7.0.0 and replacing it with the one from JRE 6.0.0 fixed the BrowserField issue for me. Don't forget to close and rerun the simulator and before reruning the application.
Here is a link to my original answer.
I too am having the same Problem and i came to know that as its the Runtime Exception so i suggest you to please write it in try catch block it seems it will work..
Thanks.
I want to suggest your one other thing that please rightclick on your project in eclipse and click on debug as... and in that click on debug configuration... and in that go into Simulator... and in that menu Select Launch Mobile Data System Connection Service with simulator... and there click on Apply and Debug it will work.
Thanks.
I got the Browser screen from your code; The thing is:
Before open the application some times you have to open the Blackberry browser and check any link(For Ex: http://google.com) even though you connect the internet settings and then run your application.
public class StartUp extends UiApplication
{
public static void main(String[]ali)
{
StartUp start=new StartUp();
start.enterEventDispatcher();
}
public StartUp()
{
MainScreen screen = new MainScreen();
BrowserField browserField = new BrowserField();;
screen.add(browserField);
pushScreen(screen);
browserField.requestContent("http://www.google.com/news");
}
}
This is a issue in blackberry please take a look into this
http://btsc.webapps.blackberry.com/btsc/microsites/search.do?cmd=displayKC&docType=kc&externalId=KB25846&sliceId=1&docTypeID=DT_SUPPORTISSUE_1_1&dialogID=1895604766&stateId=0%200%201895610037