Good morning!
I have a strange problem where i can run & authenticate my user on my ios device perfectly fine running the app using the command below.
ionic capacitor run -l --external
Using an emulator, it works sometimes, though not always.
When I try to deploy the app using Xcode, the app opens and looks normal, but if I try to send authentication requests to firebase, the app just keeps on loading, although the requests are successfully performed.
I first thought the problem was because of using LocalStorage so I rebuilt everything using Ionic Storage. But that didn't help.
I tried different versions of adding the Firebase SDK in Swift or in the Cocoa Pods file but the behaviour doesn't change so I don't believe that this is a issue with a wrong firebase configuration, what is the proper way to do this by the way - or is Ionic doing this for me already?
The output of Xcode doesn't provide any valuable information either.
2021-12-01 11:20:13.990875+0100 App[3162:27661] Writing analzed variants.
2021-12-01 11:20:14.125754+0100 App[3162:27661] KeyboardPlugin: resize mode - native
⚡️ Loading app at capacitor://localhost...
2021-12-01 11:20:14.552490+0100 App[3162:27661] Writing analzed variants.
⚡️ WebView loaded
⚡️ [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️ [log] - null
⚡️ To Native -> App addListener 60635511
2021-12-01 11:20:21.393141+0100 App[3162:27661] [Accessibility] WKContentView[#] set up: # pid: # MACH_PORT -830404096
login-function
loginWithEmail() {
let email: string = this.loginForm.get("email").value;
let password: string = this.loginForm.get("password").value;
this.loadingService.present({
message: "Logging in . . ."
});
this.authService
.loginWithEmail(email, password)
.then((result) => {
this.authService.SetUserData(result.user)
this.resetLoginForm();
this.loginSuccess();
this.router.navigateByUrl("/tabs/intensity");
})
.catch(error => {
console.log(error);
this.loginFailed(error);
});
}
login-success
loginSuccess() {
this.loadingService.dismiss();
this.toastService.present({
message: "Welcome back!",
duration: 3000,
color: "secondary"
});
}
login-with-email
import { AngularFireAuth } from "#angular/fire/compat/auth";
...
async loginWithEmail(email: string, password: string) {
return await this.afAuth.signInWithEmailAndPassword(email, password);
}
set user-data function
SetUserData(user) {
this.user = user;
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);
const userData: User = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
photoURL: user.photoURL,
emailVerified: user.emailVerified
}
return userRef.set(userData, {
merge: true
})
}
Running it multiple times some times I get this error.
API error: <_UIKBCompatInputView: 0x7fb965726040; frame = (0 0; 0 0); layer = <CALayer: 0x600002f718a0>> returned 0 width, assuming UIViewNoIntrinsicMetric
I am really stuck on this and would appreciate any help. Thank you & kind regards.
Ionic 6.18.1
Angular 12.1.5
Xcode Version 13.1 (13A1030d)
Related
I am following the firebase docs for implementation of Cloud Messgaing.
Receiving and handling messages while my ionic app is in the background works fine but when handling same in foreground I am running into issues.
This is the code:
PushNotifications.addListener('pushNotificationReceived',
(notification : PushNotificationSchema) => {
alert("Push received while app open: " + JSON.stringify(notification));
const title = notification.notification.title;
const body = notification.notification.body;
const page = notification.notification.data.department;
alert ("Notification: department = " + page + " Title : " + title);
//console.log("NOTIFICATION REC IN APP FOREGROUND: " + title + " AND BODY : " + body);
if (page){
this.router.navigate(['/'+page]);
}
},
);
The first alert with details of the notification executes every time, but nothing after.
In the Xcode console I see an error but there is no description:
Any idea what the issue might be with my ionic code or how to determine the error thrown in Xcode would be appreciated.
Hope this is helpful for some as I found there are allot of potential answers out there but the only solution I found is as follows:
Add this to the capacitor.config.json of your Ionic project:
"plugins": {
"PushNotifications": {
"presentationOptions": ["badge", "sound", "alert"]
}
}
Then build / synch your ionic app:
ionic build
ionic cap sync
See Capacitor Docs here for more details.
I'm getting an error after upgrading to NS 7 and building in xcode. I can build successfully from the CLI, run the app and everything is fine but when I build in xCode and run on physical device or simulator and try to log in, I get this error.
In the log outputs self = (SAMKeychainQuery*) & password = (NSSTRING *) nil so it's not getting the password value but why would it have access to it when building from the CLI but not Xcode?
I'm running "#nativescript/core": "^7.0.13", "#nativescript/ios": "7.0.6", Xcode 12.
Here is my password textfield:
<TextField
:isEnabled="!processing"
ref="password"
class="input placeholderColor"
hint="Password"
secure="true"
v-model="user.password"
#loaded="passwordTextField"
:returnKeyType="isLoggingIn ? 'done' : 'next'"
fontSize="18"
/>
//login function
async login(user) {
try {
console.log("in login() in authservice")
const loginRequest = await firebase.login({
type: firebase.LoginType.PASSWORD,
passwordOptions: {
email: user.email,
password: user.password,
},
});
const handleLogin = await this.handleLogin(loginRequest);
return handleLogin;
} catch (error) {
return error;
}
}
My login() function isn't even firing when I build from Xcode but again all is well from the CLI.
Completely removing the #nativescript/secure-storage plugin then ns clean and reinstalling secure-storage plugin worked.
Still have no idea why it was working from CLI and not Xcode if the plugin wasn't functioning properly though.
I'm trying to connect to a Postgres database from my Heroku node app, which works when running locally, both through node and by running the heroku local web command, but when running it on Heroku, it times out while waiting for pool.connect
I'm running the following code snippet through the Heroku console (I've also tried using this code in my app directly, but this is more efficient than redeploying each time):
node -e "
const { Pool } = require('pg');
const pool = new Pool({
connectionTimeoutMillis: 15000,
connectionString: process.env.DATABASE_URL + '?sslmode=require',
ssl: {
rejectUnauthorized: true
}
});
console.log('pool created');
(async() => {
try {
console.log('connecting');
const client = await pool.connect(); // this never resolves
console.log('querying');
const { rows } = await client.query('SELECT * FROM test_table LIMIT 1;');
console.log('query success', rows);
client.release()
} catch (error) {
console.log('query error', error);
}
})()
"
Things I've tried so far:
Using the pg Clientinstead of Pool
Using ssl: true instead of ssl: { rejectUnauthorized: true }
Using client.query without using pool.connect
Increased and omitted connectionTimeoutMillis (it resolves quickly when running locally since I'm querying a database that has just one row)
I've also tried using callbacks and promises instead of async / await
I've tried setting the connectionString both with the ?sslmode=require parameter and without it
I have tried using pg versions ^7.4.1 and ^7.18.2 so far
My assumption is that there is something I'm missing with either the Heroku setup or SSL, any help would be greatly appreciated, Thanks!
I have tried it a lot but not able to figure out why my tests are not running on Browser Stack.
1 - Package that i have installed
nativescript-dev-appium
Steps that i have done successfully are as follows:
1 - APK uploaded to Browser Stack.
2 - Used command to run test: npm run e2e android.
Below are the processes which happens successfully on browser stack but at last point it always timeout.
Initializing Device
00:14
1
Downloading App
00:14
6
Installing App
00:14
3
Setting Up Appium
00:14
1
Setting Up Network Connection
00:21
7
Launching App
01:53
0
STOP SESSION
IDLE TIMEOUT
Code is as follows:-
var wd = require('wd');
var assert = require('assert');
var asserters = wd.asserters;
var capabilities = {
'device' : 'Samsung Galaxy S8',
'os_version' : '7.0'
}
Object.assign(capabilities, {
'browserstack.user' : 'nitintayal1',
'browserstack.key' : 'WhpbGSn97yyy2HSY3XtN',
'project': 'My First Project',
'build' : 'My First Build',
'name': 'Bstack-[Node] Sample Test',
"app" : "bs://ee1e2103d4826968e28630ccee562059ec10fadd",
"automationName":"UIAutomator2"
});
let driver = wd.promiseRemote("http://hub-cloud.browserstack.com/wd/hub");
driver
.init(capabilities)
//Write your code here
.then(function(){
assert(true);
})
.fin(function() { return driver.quit(); })
.done();
I am in the process of writing unit/behavioural tests using Mocha for a particular blockchain network use-case. Based on what I can see, these tests are not hitting the actual fabric, in other words, they seem to be running in some kind of a simulated environment. I don't get to see any of the transactions that took place as a part of the test. Can someone please tell me if it is somehow possible to capture the transactions that take place as part of the Mocha tests?
Initial portion of my code below:
describe('A Network', () => {
// In-memory card store for testing so cards are not persisted to the file system
const cardStore = require('composer-common').NetworkCardStoreManager.getCardStore( { type: 'composer-wallet-inmemory' } );
let adminConnection;
let businessNetworkConnection;
let businessNetworkDefinition;
let businessNetworkName;
let factory;
//let clock;
// Embedded connection used for local testing
const connectionProfile = {
name: 'hlfv1',
'x-type': 'hlfv1',
'version': '1.0.0'
};
before(async () => {
// Generate certificates for use with the embedded connection
const credentials = CertificateUtil.generate({ commonName: 'admin' });
// PeerAdmin identity used with the admin connection to deploy business networks
const deployerMetadata = {
version: 1,
userName: 'PeerAdmin',
roles: [ 'PeerAdmin', 'ChannelAdmin' ]
};
const deployerCard = new IdCard(deployerMetadata, connectionProfile);
console.log("line 63")
const deployerCardName = 'PeerAdmin';
deployerCard.setCredentials(credentials);
console.log("line 65")
// setup admin connection
adminConnection = new AdminConnection({ cardStore: cardStore });
console.log("line 69")
await adminConnection.importCard(deployerCardName, deployerCard);
console.log("line 70")
await adminConnection.connect(deployerCardName);
console.log("line 71")
});
Earlier, my connection profile was using the embedded mode, which I changed to hlfv1 after looking at the answer below. Now, I am getting the error: Error: the string "Failed to import identity. Error: Client.createUser parameter 'opts mspid' is required." was thrown, throw an Error :). This is coming from
await adminConnection.importCard(deployerCardName, deployerCard);. Can someone please tell me what needs to be changed. Any documentation/resource will be helpful.
Yes you can use a real Fabric. Which means you could interact with the created transactions using your test framework or indeed other means such as REST or Playground etc.
In Composer's own test setup, the option for testing against an hlfv1 Fabric environment is used in its setup (ie whether you want to use embedded, web or real Fabric) -> see https://github.com/hyperledger/composer/blob/master/packages/composer-tests-functional/systest/historian.js#L120
Setup is captured here
https://github.com/hyperledger/composer/blob/master/packages/composer-tests-functional/systest/testutil.js#L192
Example of setting up artifacts that you would need to setup to use a real Fabric here
https://github.com/hyperledger/composer/blob/master/packages/composer-tests-functional/systest/testutil.js#L247
Also see this blog for more guidelines -> https://medium.com/#mrsimonstone/debug-your-blockchain-business-network-using-hyperledger-composer-9bea20b49a74