Install hybrid not showing the opt-in notification message - android

I have a hybrid app in my QA environment and we don't see the opt in notification message on any device when the app is install.. This work on my local machine that uses my local eclipse MFP..
I expect to see the prompt:
"Rand jobs Would like to sent you notification
Notification may include alert, sound
these can be configured in Settings
Dont't Allow| OK
Can you please provide some hints on how to get this working again.. No phone are getting register...
I verify that certs and port are open..
Thanks

Are you using the same physical device during development and QA, and the same application ID?
This may be the issue: Reset push notification settings for app
The steps to reset iOS to recognize the app as a new app with push requests:
Delete your app from the device.
Turn the device off completely and turn it back on.
Go to Settings > General > Date & Time and set the date ahead a day or more.
Turn the device off completely again and turn it back on.

Use the WL.Server.sendMessage method. The appName and options parameters are
mandatory.
Specify the tagNames as an array in the options.target.tagNames object. In
Example, the tagNames sent in the procedure are in a loop to fill the
options.target.tagNames array.
Specify the message to be sent as text in options.message.alert.
For example :
function submitNotification(appName, tagNames, message)
{
var options = {};
options.message = {};
options.message.alert = message;
options.target = {};
options.target.tagNames = [];
for(var i=0; i<tagNames.length; i++){
options.target.tagNames.push(tagNames[i]);
}
var delayTimeOut = WL.Server.sendMessage(appName, options);
WL.Logger.warn("notificationTimeout"+delayTimeOut);
}
source Book:
Extending IBM Business
Process Manager to the Mobile
Enterprise with IBM Worklight

Related

How to get a unique identifier for iphone and android

I need to get a unique number for every device for my cordova app (iOS/Android) The ID must be the same when user closes the app or install a new version
I cannot used the UUID from the "cordova device plugin" because the UUID changes when the user upgrade to a new version so it wouldn't work for me.
I have tried generating a unique number and storing it on the phone. However, I run into an issue where the information is not persisted.
This happens when the user install the app and then remove the app from the background. Otherwise , the data is saved
any ideas?
You can use the serial number of the phone as a unique identifier
One possibility is to use cordova-plugin-cloud-settings which allows you to persist user settings in cloud storage across devices and installs.
Install it:
cordova plugin add cordova-plugin-cloud-settings
Use it to store a GUID:
var settings = {
GUID: 12345678
}
cordova.plugin.cloudsettings.save(settings);
The nice thing about this solution is it doesn't need any special user permissions.
If you really want a unique device ID (vs unique user ID) then you could use the UniqueDeviceID plugin.
However, note that on Android this uses the SIM ID to obtain an identifier so requires READ_PHONE_STATE permission which displays a user permissions prompt "Allow to make and manage phone calls", which is not great for the trust of your users.
Use the MAC address:
cordova plugin add cordova-plugin-ip-mac-address
var params = {};
addressimpl.request("getMACAddress", JSON.stringify(params), function(message) {
alert("mac address "+message);
}, function() {
alert("failed on get mac address");
});
From here

Azure -> Easy api in Node.js-> how to send android push notifications?

We are using azure easy API (node.js) for our mobile app. We have set up notification hubs already and have tested them - they all seem to be working. However, we are not sure how to invoke these notification hubs within the easy API - we have followed the entire documentation provided by Microsoft (e.g.: http://azure.microsoft.com/en-us/documentation/articles/notification-hubs-nodejs-how-to-use-notification-hubs/) and have tried out multiple things.
Can someone point to examples / code snippets on how to send push notifications specifically from Easy API?
thanks
Sankar
As for your situation, you could follow the steps below to achieve your purpose.
Once your notification hub is set up, go to the Settings menu for
your App Service and click on the Easy APIs option. Click on the +
Add button and fill in the form.
Click on the API and then click on Edit script. This will open Visual Studio Online. This will allow you to edit the script online.
edit notification.js file with following content:
var azure = require('azure-sb');
module.exports = {
"post": function (req, res, next) {
var hubname = 'yourhubname';
var connectionstring = 'yourconnectingstring';
var notificationHubService = azure.createNotificationHubService(hubname, connectionstring);
var payload = {
data: {
message: 'Hello!'
}
};
notificationHubService.gcm.send(null, payload, function(error) {
if(!error) {
res.status(200).send('succ');
}
});
}
};
Note: Replace your own hubname and connectionstring above.
Install azure-sb module through Kudu. Go back to the Azure Portal, select your App Servcie, then Tools, followed by Kudu. Click on the PowerShell version of the Debug console.
Change directory into site/wwwroot, then type the following into the console:
npm install –-save azure-sb
test your easy API by Postman:
Eventually, your client device will receive the notification:
Help it helps. Any further concern, please feel free to let me know.

NotificationsRegistrationHandler is not being called on iOS

I have an app working and published in the Apple's app store. We are developing an update with new features and I noticed that the NotificationsRegistrationHandler is not being called anymore on iOS when the user accepts to receive notification (in Android is working fine). Which means the application is not getting the "DeviceToken", so we are unable to send notification. The proc. is very simple, and doesn't look like the issue because it's working for Android devices:
for each
where DeviceType = &DeviceType // enum domain SmartDeviceType
where DeviceId = &DeviceId // Character(128)
DeviceToken = &DeviceToken // Character(255)
DeviceName = &DeviceName // Character(128)
when none
new
DeviceType = &DeviceType
DeviceId = &DeviceId
DeviceToken = &DeviceToken
DeviceName = &DeviceName
endnew
endfor
What I have tried so far:
Generate and install new distribuition certificates and provision profiles.
Rebuild All, Build With This Only, etc.
Tested in "TestFlight" also.
Tested in different devices.
The published app right now is working, however I fear to publish this upgrade and screw up the notification.
I'm using GeneXus Evo 3 U2, .NET generator and Oracle.
Any suggestion how to fix this?
EDIT: Tested with distribuition certificate and sandbox=false, builded for distribuition and sended to testflight, same problem. =/
Have you checked that in the Provisioning Profile (developer.apple.com) the Push Notification service is active:
Enabled Services:
Game Center, In-App Purchase, Push Notifications
I fixed, here is what I did:
Updated from "U2" to "U8". Since "U8" have some OSX and XCode version requirements I updated both to the lastest versions.
Now "NotificationRegistrationHadler" is being called as normal.

Azure notification hub cross platform push

I need to send a push notification to mobile devices that have registered on my notification hub.
The hub is set up to allow windows phone, apple and android devices to register, and I have the appropriate keys and certificates in place. (According to the documentation!)
I am using the latest release of the Microsoft.Azure.NotificationHubs namespace, version 2.16, as advised by the NuGet package manager.
I want to send one message, to all registrations as well as sending a message to a specific device. I can see the devices have all registered correctly with the hub, and have tags that allow me to send notifications to them.
I am trying to use the SendDirectNotificationAsync() method
that takes a Dictionary and a string tag as parameters.
I have also tried the SendNotificationAsync() method that takes a Notification object as a parameter.
Neither method causes a notification to appear on my windows phone with the parameters I have provided, so without an example or more information from the help files, I am stuck.
I cannot find any current examples using these methods and classes.
The examples I have found pre-date the release, and do not show what to send to the notification hub for a cross platform notification to work.
I know these have only just been released, but any help / guidance would be appreciated, as I have reached a complete dead-end with this.
Just a quick update...
Although I never got this to work as I wanted to (as described above), what I ended up doing was to use each platforms native notification as below;
var result1 = await hub.SendMpnsNativeNotificationAsync(windowstoast, mobileDeviceId);
var result2 = await hub.SendGcmNativeNotificationAsync(androidToast, mobileDeviceId);
var result3 = await hub.SendAppleNativeNotificationAsync(iOStoast, mobileDeviceId);
The 'toast' was formatted as per the individual platforms requirements in the documentation.
The 'mobileDeviceId' was the tag that each device registered with the notification hub.
So, clumsy, but it works reliably to achieve the same end.
I still would like to get the cross platform way to work though. Will look into it a bit more when I have time.

Request desktop site option on mobile devices

Many Mobile devices like my android phone have a 'request desktop site' option. I'm in the process of building mobile websites and want to make that native feature work.
What is expected on our end as developers? Is there a GET request for example: leave_mobile=1 or is it the device itself changing the user-agent to trick the application thinking its just another desktop?
I've done some tests on my android devices and read out the user agents and seems like it changes. So What I did to make this native option work was to capture the initial user agent into a session and on each page request compare it with the one being sent.
If the user agent is not the same, revalidate if it is a mobile device and if true overwrite session user-agent with new one. If however the new validation fails, it probably wants to find the desktop version so send a new header redirect.
$DesktopSite = 'www.example.com';
$UserAgent = $_SERVER['HTTP_USER_AGENT'];
if (!isset($_SESSION['use_mobile'])){
$_SESSION['use_mobile'] = 1;
$_SESSION['user_agent'] = $UserAgent;
} else if ($_SESSION['user_agent'] != $UserAgent){ // Check if user-agent has changed
if(!preg_match( /*preg match from http://detectmobilebrowsers.com/ */){
$_SESSION['use_mobile'] = 0;
$_SESSION['user_agent'] = $UserAgent; // Overwrite old user-agent with new one.
header("location: $DesktopSite"); // Send visitor to desktop website.
} else {
// Visitor still seems to be mobile.
$_SESSION['use_mobile'] = 1;
$_SESSION['user_agent'] = $UserAgent; // Overwrite old user-agent with new one.
}
}
If you enter the mobile website on a desktop for the first time, it will not send you back to the desktop site because it will create the session first. This way you can check the mobile site on a desktop as well instead of being send back. If however you change your user-agent, you will be revalidated and redirected on fail.
Works perfectly. Hope this may help anyone in the future.

Categories

Resources