difference between udid and client_identification_sequence - quickblox

I cannot understand somethings about the push notification with quickblox
I have a chat (a webchat) in a webview in a Xamarin apps (i know isn't very clever approach)
i try to create a subscrition via javascript
but i cannot undestand the way for calculate
uuid and client_identification_sequence
var params = {
notification_channels: 'gcm',
device: {
platform: 'android',
udid: '538a068a-d66a-44d4-86c8-18ffed7f20d8'
},
push_token: {
environment: 'development',
client_identification_sequence: ''
}
}; 
QB.pushnotifications.subscriptions.create(params, function (err, res) {
debugger;
if (err) {
debugger;
// error
} else {
debugger;
// success
}
});
i've tried to calculate the uuid with "Xam.Plugin.DeviceInfo"
but what is the way for client_identification_sequence?
should I take this value from the "apns" (for apple push notification) but where?
I have the same roblem with the xamarin project
var d = await wbWrapper.SubscribeForPushNotificationAsync([pushtoken], CrossDeviceInfo.Current.GenerateAppId());
thankyou

uuid - it's your device unique identifier. It's actually can be anything that uniquely identify current particular device.
client_identification_sequence - it's your push token.
For Android - it's registration id (or registration token).
For iOS - it's device token

Related

React Native - Is there a way to use bluetooth in peripheral mode?

I am developing an app in ReactNative offline.
One of the functionalities is to use bluetooth to synchronize the data (that the app was collecting) with other devices that use the same app.
I started to develop this task with the react-native-ble-manager library, i can connect from device A to device B, but I don't understand how to listen to the incoming connection in device B. I need to know this to show a certain view.
can anybody help me?
I am using the correct library?
Thanks!
You can't use only the react-native-ble-manager for this project. The library states in its readme that it is based on cordova-plugin-ble-central, which can only act as a central. For a BLE connection you need a central and a peripheral.
Take a look at react-native-peripheral. It allows you to act as a perihperal, create a characteristic with some data, add it to a service and register it so other devices can find it. This is their usage example:
import Peripheral, { Service, Characteristic } from 'react-native-peripheral'
Peripheral.onStateChanged(state => {
// wait until Bluetooth is ready
if (state === 'poweredOn') {
// first, define a characteristic with a value
const ch = new Characteristic({
uuid: '...',
value: '...', // Base64-encoded string
properties: ['read', 'write'],
permissions: ['readable', 'writeable'],
})
// add the characteristic to a service
const service = new Service({
uuid: '...',
characteristics: [ch],
})
// register GATT services that your device provides
Peripheral.addService(service).then(() => {
// start advertising to make your device discoverable
Peripheral.startAdvertising({
name: 'My BLE device',
serviceUuids: ['...'],
})
})
}
})
There is a section about dynamic values where they explain how you can use the onReadRequest and onWriteRequest callbacks to listen to read and write operations on the peripheral and even return dynamic values on each read request:
new Characteristic({
uuid: '...',
properties: ['read', 'write'],
permissions: ['readable', 'writeable'],
onReadRequest: async (offset?: number) => {
const value = '...' // calculate the value
return value // you can also return a promise
},
onWriteRequest: async (value: string, offset?: number) => {
// store or do something with the value
this.value = value
},
})

Detect beacons uuid and name with react native

I have simulated a beacon from computer and i'm trying to read beacon info (uuid,identifier etc) from my react native app.
I decided to use this library
https://github.com/dotintent/react-native-ble-plx as the library.
The issue i'm facing is although it shows some devices when i scan, the name,uuid and other info shows as null.
For ex:
'device', { serviceUUIDs: null,
isConnectable: null,
overflowServiceUUIDs: null,
txPowerLevel: null,
serviceData: null,
manufacturerData: 'TEACFCd6h5jcoxKqh9ACQqwTAAOBqZYcxQ==',
name: null,
mtu: 23,
rssi: -47,
solicitedServiceUUIDs: null,
localName: null,
id: '32:BD:32:6C:E9:C2',
And this is my code
const bluetoothInstance = new BleManager();
const scanAndConnect = () => {
bluetoothInstance.startDeviceScan(null, { allowDuplicates: true }, (error, device) => {
console.log('device', device);
console.log('error', error);
if (error) {
// Handle error (scanning will be stopped automatically)
return;
}
if (device?.name === 'MyProjectName') {
bluetoothInstance.stopDeviceScan();
} else {
// bluetoothInstance.stopDeviceScan();
}
});
};
useEffect(() => {
bluetoothInstance.onStateChange((state) => {
console.log('state', state);
if (state === 'PoweredOn') {
scanAndConnect();
}
}, true);
}, []);
How i can read the beacon uuid and name? Is there any other library you can recommend? Or is there something missing in the code? Any help would be appreciated.
The scanning code is probably working fine. The information you are looking for is either not always present or present in a different field.
The iBeacon Proximity UUID is actually embedded inside the manufacturerData field. However, on iOS devices this field is deleted by the operating system for all iBeacon packets as a security mechanism by Apple. Apple forbids using the CoreBluetooth framework (used by react-react-native-ble-plx under the hood) to detect iBeacon. On iOS you must use CoreLocation. For that you can try react-native-beacons-manager. For Android, react-native-ble-plx will work fine to detect iBeacon but you must parse out the beacon fields yourself from the manyfacturerData field.
The Bluetooth name is only populated (in the name field) if a scan response packet containing the name has been received recently before the main advertisement packet. It is unclear how iOS will handle this process for forbidden iBeacon advertisements, but it will probably work for non-iBeacon advertisements just fine. On Android it will work fine, too. Just do not expect it to be populated 100% of the time on either platform.

How to send session info and do automated page tracking in expo react native segment and amplitude integration

I am using Segment[expo-analytics-segment] to send tracking info to Amplitude(Configured as the destination in app.segment.com) in an expo react native app. Though I am sending session info(epoch time) - The session always gets registered as -1, hence I am unable to access 'funnel' feature in Amplitude.
Also - How do we enable automatic page tracking in expo segment+amplitude configuration?
This is what I have done so far in App.tsx
Segment.initialize({
androidWriteKey: 'androidKey', // from Segment
iosWriteKey: 'iOsKey', // from segment
});
global.epochInMilliSeconds = Date.now();
Segment.identifyWithTraits(
user.sub,
{ email: 'notgood#gmail.com' },
{
event: 'App Started',
integrations: {
Amplitude: {
sessionId: global.epochInMilliSeconds,
},
},
}
);
Segment.trackWithProperties(
'App Started',
{ email: 'fancyemail#gmail.com' },
{ integrations: { Amplitude: { session_id: global.epochInMilliSeconds } } }
); <------------------- Did not work. Session id is -1**
Segment.track('App Started'); // <-----------------------Session id is -1
More info - https://github.com/expo/expo/issues/10559
I followed this example for the above code sample: https://community.amplitude.com/instrumentation-and-data-management-57/how-do-we-set-session-in-amplitude-while-using-segment-in-cloud-mode-111
Amplitude website mentions that session Ids are not automatically tracked.
https://help.amplitude.com/hc/en-us/articles/217934128-Segment-Amplitude-Integration
In case the link changes, it says:
6. Why do all of my events have a sessionId of -1?
You need to use Segment's client-side bundled integration to have our native SDKs track Session IDs for you.

Send push notifications to a specific logged user with pinpoint

Im developing a react native app integrated with aws-amplify and aws mobile hub.
We currently logged our user into cognito.
im trying to send a push notification to a specific endpoint Id, but i cannot see how to set that endpointId, in the node js (im using lambda) documentation for pinpoint only exist getEnpoint, but requires EnpointId and i cannot find where is it.
app.post('/asdf/get/endpoint', function (req, res) {
pinpoint.getEndpoint({
ApplicationId: APP_ID_PINPOINT,
EndpointId: req.body.userId
}, (err, data) => {
if (err) {
res.json({ error: err });
} else {
res.json({ data: data });
}
});
});
How can set the enpointId (userId) to an already logged user and then, every time i need to send a push to him i just get that enpoint and send a push to all the devices attached to it?
Or, i have to store all the tokens from the user (DynamoDb), and send messages to all the devices separately? (with pinpoint sendMessage)

Push notification with Appcelerator (ACS) on Android

I'm trying to implement push notification with Appcelerator Cloud Service on Android But I have some issues ... tiapp.xml here :
<sdk-version>2.0.2.GA</sdk-version>
<modules>
<module platform="commonjs" version="2.0.5">ti.cloud</module>
<module platform="android" version="2.0.5">ti.cloudpush</module>
</modules>
Android runtime v8 and ti.cloudpush included, here is my app.js file
var win = Ti.UI.createWindow({
backgroundColor:'#ccc',
title:'Android Cloud Push Notification'
})
var CloudPush = require('ti.cloudpush');
CloudPush.debug = true;
CloudPush.enabled = true;
CloudPush.showTrayNotificationsWhenFocused = true;
CloudPush.focusAppOnPush = false;
var deviceToken;
var Cloud = require('ti.cloud');
Cloud.debug = true;
var submit = Ti.UI.createButton({
title : 'Register For Push Notification',
color:'#000',
height : 53,
width : 200,
top : 100,
});
win.add(submit);
submit.addEventListener('click', function(e) {
CloudPush.retrieveDeviceToken({
success: function deviceTokenSuccess(e) {
alert('Device Token: ' + e.deviceToken);
deviceToken = e.deviceToken
loginDefault();
},
error: function deviceTokenError(e) {
alert('Failed to register for push! ' + e.error);
}
});
});
function defaultSubscribe(){
Cloud.PushNotifications.subscribe({
channel: 'chanel',
device_token: deviceToken,
type: 'android'
}, function (e){
if (e.success) {
alert('Subscribed for Push Notification!');
}else{
alert('Error:' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
function loginDefault(e){
//Create a Default User in Cloud Console, and login
Cloud.Users.login({
login: 'android',
password: 'android'
}, function (e) {
if (e.success) {
alert("login success");
defaultSubscribe();
} else {
alert('Error: ' +((e.error && e.message) || JSON.stringify(e)));
}
});
}
CloudPush.addEventListener('callback', function (evt) {
//alert(evt);
alert(evt.payload);
});
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
//Ti.API.info('Tray Click Launched App (app was not running)');
alert('Tray Click Launched App (app was not running');
});
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
//Ti.API.info('Tray Click Focused App (app was already running)');
alert('Tray Click Focused App (app was already running)');
});
win.open();
I had the user android / android in the Appcelerator cloud console for the development mode. Launched my app to my device with debogage mode
On the app : Just click on the button "register for push notification" and see 3 alerts
1) Device Token : " all numbers "
2) login success
3) Subscribed for Push Notification!
On the Appcelerator Cloud console :
Logs -> see login & subscribe, opened it and everything's ok
Push Notifications -> 1 Android clients subscribed to push notifications. And send one throught push notifications with alert & title
And nothing appears at all ... try reboot, try to turn the app off and send another one, nothing.
I was using a device (LG OPTIMUS ONE) with android 2.2.1 with internet on it (wifi). So, I tried with another phone (SAMSUNG GALAXY S2) 3.3.2 with internet on it (wifi)
And the only change is in the cloud console :
Push Notifications -> 2 Android clients subscribed to push notifications.
But it is the same, no notification appears.
Please, I really need help for this, I succeed with iOS in 2 days and I do not understand what is the big deal here ?
I don't think I need to register with Google C2DM for using ACS.
ACS use MQTT protocol for sending push.
(I followed this step by step tut : http://www.titaniumtutorial.com/2012/06/appcelerator-cloud-push-notification-in.html)
Have you already done one project with push notification on Android & Ti ?
I checked my settings and everything is fine.
But, because I'm desperate, I also register to C2DM and nothing better, I guess I have to wait a bit more before testing.
I use the upush module in the Marketplace, took me 10 minutes to gtet it up and running, saved me loads of time.
Have you registered with Google C2DM? You need to fill out the form at https://developers.google.com/android/c2dm/signup to send notifications to the device. Make sure you have your correct App ID in the Appcelerator Cloud Settings.