Github doesn't support cloning with username password.
With personal access token (PAT):
git clone https://<PAT>@github.com/path/repo.git
Github doesn't support cloning with username password.
With personal access token (PAT):
git clone https://<PAT>@github.com/path/repo.git
This article shows example codes in both iOS side and server side to let you know how to make use of Firebase Cloud Messaging (FCM) to implement push notification for your iOS app.
You need to use the Firebase for your iOS app.
I will not go into detail on how to setup in Xcode side nor the certification issues. There are tons of articles on the web for those. The steps for this part are same for any platforms.
Almost every iOS app needs push notification. And you don’t want to deal with complicated details.
Here is the basic components you need to know.
If you want to implement the server side logic, it is possible. However, for most of us, we want to get rid of the trouble and here the FCM comes.
We need to do these steps.
On the iOS app, we have several ways to receive messages from the FCM. In this case, for the simplicity, we choose “subscription by topic” approach. The Topic is actually a string, and our app subscribe it via a call:
Messaging.messaging().subscribe(toTopic: topicString)
Please note that the topic string can only accept certain characters as shown in this regular expression:
[a-zA-Z0-9-_.~%]+
Let me use an example to show how we trigger the push notification.
In this example project, it uses the Realtime database of Firebase. This is a JSON-like structure database and we refer data using path. In this use case, we want to send out a push notification whenever there is a new node (data object) is inserted to the node “/messages”. This is actually a new message is sent by some user to another.
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
exports.sendPush = functions.database.ref('/messages/{pushId}')
.onCreate((snapshot, context) => {
const msgid = context.params.pushId;
const msg = snapshot.val();
const peer = msg.peer ;
const room = msg.chatroomid;
const text = msg.text ;
const sender = msg.userid;
const sendername = msg.username ;
// just in case. old version of messages may not have this field.
if (!peer) {
return 0;
}
// room id has colon, but it is not valid for firebase topic name.
// this matches what the app subscribes for each room.
const topic = peer + "-" + room.replace(":","-");
const message = {
notification: {
title: sendername,
body: text
},
data: {
to: peer ,
sender: sender ,
room: room,
sendername: sendername,
text: text
},
topic: topic
};
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
functions.logger.log('Successfully sent message:', response);
})
.catch((error) => {
functions.logger.log('Error sending message:', error);
});
});
As you see, the key point here is to construct a JSON structure to represent your message to send to your iOS app. Please look at the message variable. It consists of 3 parts.
The notification
: This is what displays in the push notification banner on the iOS device.
The data
: This is the data you want to send to the iOS app to process with. The name of the fields seem could be any string but please try to avoid using strange ones and be simple, and avoid symbols.
The topic
: This is the FCM topic string that your iOS app subscribes to.
We hope this is helpful. Please let me know in comments that you have any doubts. We try to make this writing short. So you would still need to check Firebase documentations to know how it really works.
If you want to sync your app's data to iCloud, go to the Signing & Capabilities settings for your app's target, then:
…and that's it: your app is now configured to sync all its data with iCloud.
Tip: Although you can attempt to test iCloud support in the simulator, I've found it rarely works well – it's much better to test on a real device.
Although the configuration is complete, you might need to make some changes to your SwiftData models because CloudKit has a few very specific requirements. Annoyingly, if you don't follow these requirements your iCloud sync will silently fail, so here they are:
https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud
Github doesn't support cloning with username password. With personal access token (PAT): git clone https:// <PAT> @ github.com/pa...