Sending Parse push notifications to multiple applications from single application - ios

I am wondering if it is possible to send push notifications to different IOS applications from only one IOS application via Parse.com API. I can already send a push notification in same application but I want to send to different applications of mine, from a single application.

You can technically use the REST API from Cloud Code, calling back in to Parse with different headers.
Parse.Cloud.httpRequest({
method: "POST",
headers: {
"X-Parse-Application-Id": YOUR_APP_ID,
"X-Parse-REST-API-Key": REST_API_KEY,
"Content-Type": "application/json"
},
body: {
"data": {
"alert": "Yo"
}
},
url: "https://api.parse.com/1/push"
}).then(function() {
console.log("Successful push");
}, function(error) {
console.log(error);
});
Taken from official forums here: Click here

Related

How to show local notification upon receiving silent push?

We are building a react-native IOS application, which uses FCM at the backend and notifee at the front end. Everything works, but there are often times when a FCM-data-push is sent but the notification is not shown on IOS if the app is in killed state. Following is the message object that we are sending to the FCM server through firebase-admin's node package.
const message = {
token: fcmToken,
data: prepared,
android: {
priority,
},
apns: {
payload: {
headers: {
'apns-priority': 10,
'apns-push-type': 'background',
},
aps: {
'content-available': 1,
},
},
},
};
It is required to register a task that runs in the background while the app is killed then the registered task handle notification event listens and pushes notification.
Consult this package for background task - https://www.npmjs.com/package/react-native-background-task

LinkedIn V2 API video sharing error or did I miss something?

I am using the ugcPost endpoint to generate my shares.
According to documentation I am making a pre-upload request (with multipart settings included), and I receive what seems like the appropriate multipart response to that request. However, there are absolutely NO aws key-id or anything... the headers mentioned in the sample are not the ones I am receiving after registering the upload as multipart.
They mention this response to a single part upload request:
{
"value": {
"asset": "urn:li:digitalmediaAsset:C5400AQHpR1ANqMWqNA",
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5400AQHpR1ANqMWqNA,urn:li:digitalmediaMediaArtifactClass:aws-userUploadedVideo)",
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {
"Content-Type": "application/octet-stream",
"x-amz-server-side-encryption": "aws:kms",
"x-amz-server-side-encryption-aws-kms-key-id": "e10ace24-blah-4977-bar-89foo193e2ab"
},
"uploadUrl": "https://video-uploads.s3-accelerate.amazonaws.com/C5400AQHpR1ANqMWqNA/aws-userUploadedVideo?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20180120T000018Z&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-server-side-encryption%3Bx-amz-server-side-encryption-aws-kms-key-id&X-Amz-Expires=86400&X-Amz-Credential=AKIAJYU2MA%2F20180120%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=f7c0756a80998786766588878768778768977687d4c687b3f1a0e8"
}
}
}
}
However, I am receiving something like this when I register a multipart upload:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MultipartUpload": {
"metadata": "base64_encoded_metadata",
"partUploadRequests": [
{
"headers": {
"Content-Length": "5242880",
"Content-Type": "application/octet-stream"
},
"urlExpiresAt": 1558459064787,
"byteRange": {
"lastByte": 5242879,
"firstByte": 0
},
"url": "https://video-uploads-prod.s3-accelerate.amazonaws.com/ABCD/aws-userUploadedVideo?uploadId=xxx&partNumber=1&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=xxx&X-Amz-SignedHeaders=content-length%3Bcontent-type%3Bhost&X-Amz-Expires=86400&X-Amz-Credential=xxx&X-Amz-Signature=xxx"
},
{...other_parts...}
]
}
}
}
}
As I understand this, I am supposed to iterate on the partUploadRequests array and use the headers contained on each 'chunk' there to make the multipart upload. These headers that I get... I am not getting the "x-amz-server-side-encryption" headers back from LinkedIn when I request it as multipart. So when I attempt the upload of a chunk I get an error from amazon saying something about the signature...
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated...(truncated)
I have had no problems making this request outside the realm of multi-part uploads... but when I try to make it multi-part, it fails royally.
Consistent with their api docs, I'd expect to get a 4xx error if I didn't have permissions to perform this action... but I am not getting such error, I just don't get the right headers back from LinkedIn?
This here is what I send in the body of the initial upload registration request:
{
"registerUploadRequest": {
"supportedUploadMechanism": ["MULTIPART_UPLOAD"],
"fileSize": 123123123,
"owner": "url:li:organization:x123123123",
"recipes": [
"urn:li:digitalmediaRecipe:feedshare-video"
],
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
]
}
}
My app has Marketing Dev. Platform access, and I am following these documentation indications: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/vector-asset-api#register-an-upload
So far, unsuccessful only when trying to do multi-part uploads. I have been able to successfully publish single image posts, and article type of posts so far... but Video uploads are eluding me...
Anyone that can shed some light on this?
EDIT: Almost instantly after posting this, (didn't show up before when I searched earlier) I found this question that seems to hint that this kind of upload is not yet supported?? So far this has a taste of errors, can anyone further confirm this is unsupported!?
Video Uploads are a restricted feature that is granted to select developers only.
Source:
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api

iOS Push notifications using cordova. The notification is never received

I created a sample Cordova app which is using "phonegap-push-plugin".
That app doesn't have any complexity. On "deviceready" I run the plugin initialization code as shown here:
var push = PushNotification.init({android: {}, ios: {
sound: true,
alert: true,
badge: true,
categories: {
invite: {
yes: {
callback: 'accept',
title: 'Accept',
foreground: true,
destructive: false
},
no: {
callback: 'reject',
title: 'Reject',
foreground: true,
destructive: false
},
maybe: {
callback: 'maybe',
title: 'Maybe',
foreground: true,
destructive: false
}
},
delete: {
yes: {
callback: 'doDelete',
title: 'Delete',
foreground: true,
destructive: true
},
no: {
callback: 'cancel',
title: 'Cancel',
foreground: true,
destructive: false
}
}
}
}})
push.on('notification', data => {
console.log(data.message);
console.log(data.title);
console.log(data.count);
console.log(data.sound);
console.log(data.image);
console.log(data.additionalData);
})
push.on('emailGuests', data => {
console.log('I should email my guests');
});
push.on('snooze', data => {
console.log('Remind me later');
});
push.on('registration', data => {
console.log(data.registrationId);
console.log(data.registrationType);
});
push.subscribe('xx', console.log)
And this is the log output to console:
=> Successfully subscribe to topic xx
// The first run (after app install) will ask for permissions. If I click allow the lines below are printed to console.
=> dCAtjhCFBcU:APA91bG90c8VhNl_BzZ-2e9fmq_9fN6jfrRNJ1LPCRIpKnZ-AG-eLY4xtX84oJRZBh2D....KtNNQ35GM8ubPF5zr8HqeB6jffs
=> FCM
In order to push I'm sending the following payload to the Legacy Server https://fcm.googleapis.com/fcm/send.
{
"priority": "high",
"to": "/topics/xx", // I tried this but I also tried to specify the device token received upon "registration" event. I did this using to:<device_token> and also using registration_ids: [<device_token>].
"notification": {
"title": "My Message",
"body": "My Message Body",
"badge": 1,
"content-available": "1", // I tried with and without
"category": "identifier", // I tried with and without
"thread-id": "id", // I tried with and without
"sound": "default",
"icon": "default"
},
"data": {
"title": "A short string describing the purpose of the notification",
"body": "The text of the alert message",
"clubId": 1000
},
"notId": 1,
"custom_key1": "value1",
"custom_key2": "value2"
}
Note: I tried every combination possible in what concerns the app state: App in background; app closed; app in foreground; The event "notification" has never fired and the push notification was never received.
The request sent to the FCM server returns a message id when I use the topic (which is understandable since other devices subscribe the topic). For that reason my android that has subscribed to the same topic receives the message. The iOS in the other hand receives nothing!
{
"message_id": 5059997308576486332
}
If I try to specify the token that I received upon registration, I will get a slightly different message. Most of the time the token received upon registration works and the results will contain a string id. But this is temporary since a few minutes later the token become "NotRegistered".
{
"multicast_id": 88880398234xxxxx7,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "NotRegistered" // <-- This happens after a few minutes. I have to delete the app and reinstall it in order to get a new token.
}
]
}
This is the build configuration
Notifications are correctly enabled on my iOS device. What am I missing?
Updated:
Accessing Apple's APN directly (yup... no FCM!)
I would like to send my push notifications through FCM but in order to determine the cause of the issues described above, I decided to try APN directly. To do this, I had to remove the from the app's config.xml, so phonegap-push-plugin can obtain a token from APN and not from FCM.
Now, using the new token and a server that uses node-apn module to communicate with APN server, I'm able to send push notifications to my iOS app. The downside of this, is that I lose the ability to push to topics since this is a FCM only feature.
The only thing that I still don't know is how to use the topic to target devices in the APN network, that are subscribed by the push.subscribe() method.
Checkout my issue here.
Any help on this too?
So, turns out there's an issue with the push plugin.
This issue only impacts users on iOS device apps that use the FCM.
If you use the APNs it works.
You can check my answer in here: https://github.com/phonegap/phonegap-plugin-push/issues/2644#issuecomment-445346335
And my initial issue reporting in here:
https://github.com/phonegap/phonegap-plugin-push/issues/2613

How to create notification groups OneSignal

In my app I've got buttons where if the user presses it they are then 'subscribed' to that channel and will receive notifications for that and which ever other ones they subscribe to. I wanted to know how to do this with OneSignal you can create user segments and send notifications to only those specific groups. So if I create a segment in OneSignal how can I register users to that segment and remove them?
Xcode, swift 3, iOS 10
Use Tags. (from FrontEnd or API)
Example using Frontend:
window.plugins.OneSignal.sendTags({key: "value", key2: "value2"});
Example using API:
URL:
https://onesignal.com/api/v1/players/PLAYER_ID
METHOD:
PUT
HEADERS:
ContentType: application/json
BODY (json):
{
"app_id": "APP_ID",
"tags": {
"key1": "value1",
"key2": "value2",
}
}

oauth.io subscribe user to youtube channel

I'm using oauth.io (https://oauth.io/) to authenticate users via google, facebook, etc. How can I subscribe user to youtube channel after authentication ?
OAuth.popup(provider, function(error, result) {
// some code to subscribe user to youtube channel
});
To subscribe a user to a youtube channel, you need to make sure that you have added the following scopes for Youtube to your OAuth.io app:
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtubepartner
Also make sure that the Youtube API is activated in your Google API console.
Then, you can subscribe the user through OAuth.io like this:
OAuth.popup('youtube')
.done(function (requestObject) {
requestObject.post('/youtube/v3/subscriptions?part=snippet', {
data: JSON.stringify({
snippet: {
resourceId: {
channelId: 'id_of_the_channel'
}
}
}),
dataType: 'json',
contentType: 'application/json; charset=utf8'
})
.done(function (r) {
// Success: the subscription was successful
console.log(r);
})
.fail(function (e) {
// Failure: the id was wrong, or the subscription is a duplicate
console.log(e);
});
})
.fail(function (e) {
// Handle errors here
console.log(e);
});
You need to specify the dataType and contentType fields as Google API doesn't accept form encoded data.
You can find more information about this Google API endpoint there:
https://developers.google.com/youtube/v3/docs/subscriptions/insert
And if you want to learn more about OAuth.io, you can consult the documentation here:
https://oauth.io/docs/overview
You'll also find a tutorial about the JavaScript SDK here:
https://oauth.io/getting-started?javascript&None
Hope this helps :)

Resources